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.

Author
Alex Barlow
Published

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.

  1. Read the search terms from my Terms tab
  2. Search Instagram for each term
  3. Collect every post link on the results
  4. Write them to my Posts tab and delete the term
Click to launch the Chrome extension. Not installed? You can create an account and try it free.Opens the Chrome extension. Free account to try.

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 Sheet
    • Spreadsheet: your sheet
    • Sheet name: Terms
  • 2.0 Loop through data
    • repeats for every row in [google-sheet-data]
    • 2.1 Go to page
    • 2.2 Wait
      • Wait time: 3000
    • 2.3 Get data from bot's current page
      • Select: the custom selector main arole="link", every post on the results page
      • Max results: the number of posts you want per term
    • 2.4 Get current bot URL
    • 2.5 Append or merge data
      • Data A: [current-url]
      • Data B: [scrape-data]
    • 2.6 Write data to a Google Sheet
      • Spreadsheet: your sheet
      • Sheet name: Posts
      • DATA: [appended-data]
      • Write options: Add to existing data
    • 2.7 Delete rows from a Google Sheet
      • Spreadsheet: your sheet
      • Sheet name: Terms
      • First row: 1
      • Last row: 1

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.

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