Scrape Instagram post links for every search term in a Google Sheet
How to scrape Instagram post links for every search term in a Google Sheet: install the Chrome extension, click Build with Browser agent, tell the agent what you want, and follow its prompts. A working bot is built and tested in minutes.
Here is how the automation works. To scrape Instagram post links for a list of search terms, loop through the terms in a Google Sheet with Loop through data, open Instagram's search URL with the term appended, collect every post link on the results with Get data from bot's current page and the selector main a[role="link"], and write them to a second tab with Write data to a Google Sheet. Each term is deleted once done.
Build the Instagram post link scraper from a description
Describe it and click the button: the agent builds and tests the scraper in your Chrome extension. Runs use your own logged-in Instagram in Chrome, on the desktop app; for a cloud run, see logins.
- Read the search terms from my Terms tab
- Search Instagram for each term
- Collect every post link on the results
- Write them to my Posts tab and delete the term
You need a Google Sheet with two tabs: Terms, one search term per row in column A with no header, and Posts, empty. Leave the Posts tab alone while the run adds to it.
The video shows the agent building the Instagram post link scraper from the four lines above, in a few minutes.
Build the Instagram post link scraper step by step
The steps the agent builds, as the Builder shows them: each step by its name, with the fields to set under it. Add them yourself in this order in the step-by-step builder, or open the agent's result there to adjust it.
- 1.0
Read data from a Google SheetSpreadsheet: your sheetSheet name: Terms
- 2.0
Loop through data- repeats for every row in
[google-sheet-data]
- 2.1
Go to pageURL: https://www.instagram.com/explore/search/keyword/?q= followed by column A of[google-sheet-data]
- 2.2
WaitWait time: 3000
- 2.3
Get data from bot's current pageSelect: the custom selector main arole="link", every post on the results pageMax results: the number of posts you want per term
- 2.4
Get current bot URL - 2.5
Append or merge dataData A:[current-url]Data B:[scrape-data]
- 2.6
Write data to a Google SheetSpreadsheet: your sheetSheet name: PostsDATA:[appended-data]Write options: Add to existing data
- 2.7
Delete rows from a Google SheetSpreadsheet: your sheetSheet name: TermsFirst row: 1Last row: 1
- repeats for every row in
Common questions about scraping Instagram post links
Why does the Instagram search page not load?
The search URL is wrong. Check the Go to page URL reads https://www.instagram.com/explore/search/keyword/?q=[google-sheet-data] with the token at the end.
Why are no Instagram post links collected?
Instagram has changed its markup, so the selector no longer matches. Open a results page and reselect a post, or update the custom selector. When a run fails, hand it to the agent and it repairs the step.
Why are the Instagram post links not written to the sheet?
The write step points at the wrong data or tab. In Write data to a Google Sheet, check DATA is [appended-data] and Sheet name is Posts.
Can I scrape Instagram post links without code?
Yes. The automation opens Instagram's own search page in your browser and reads the links off it, so there is no Instagram API, access token or script; the agent builds it from the lines above.
Can I scrape Instagram post links for a hashtag instead of a search term?
Yes. For the posts under a hashtag, and the users behind them, see scrape Instagram users from a hashtag, which starts from the hashtag page rather than a search.
Can I scrape the Instagram posts themselves, not just the links?
Yes. Feed the Posts tab to loop through a list of links and scrape each page. For the users behind a hashtag, see scrape Instagram hashtag pages for handles.
Can I scrape Facebook Marketplace for every search term the same way?
Yes. The same loop searches Marketplace for each term and writes the listings to a second tab, with the date written next to each term so the next run skips it: see scrape Facebook Marketplace for every search term in a Google Sheet.
Where do I get help?
Get in touch with support, or ask in the axiom.ai community.
Related guides
Scrape every page in a list of links into a Google Sheet
- Open each link in the Links tab of my sheet
- Scrape the title, price and description
- Add them to the Data tab
- Delete the link row once it is scraped
Scrape YouTube search results for every search term in a Google Sheet
- Read search terms from my Terms tab
- Search YouTube for each term
- Scrape the title and link of the first 10 videos
- Write them to my Videos tab with the term
Scrape Amazon product data into a Google Sheet
- Open each Amazon product link in my Google Sheet
- Scrape the title, price and rating
- Add them to the Data tab of my sheet
- Delete the link row once it is scraped