1

I'm attempting to scrape the number of likes for an Instagram post using the following query:

=IMPORTXML(A1, "//*[@id='react-root']/section/main/div/div/article/div[2]/section[2]/div/a/span")

where A1 is the url to any given Instagram post:

https://www.instagram.com/p/[Insert alphanumeric post ID]

However, this generates an "#N/A - content is empty" error.

I've played around with this for far too much time, but cannot get it to work! The xpath_query was generated using the dev console in Chrome. But all other variations I've tried also fail.

What am I doing wrong?

Rubén
  • 34,714
  • 9
  • 70
  • 166
Ben Salt
  • 11
  • 1
  • What is `importxml()`? Where does it come from? – Dominique May 16 '18 at 07:30
  • IMPORTXML seems to be a user defined function. Check whether this function comes from an Excel add-in, or whether it comes from VBA code. I strongly suspect you have something like [this](https://stackoverflow.com/questions/14165276/function-similar-to-importxml-in-excel) in your VBA code. Check whether the implementation of that function supports the parameter you've passed. – sɐunıɔןɐqɐp May 16 '18 at 07:38
  • I'm using IMPORTXML in Google sheets - it's quite commonly used. I've successfully generated another ImportXML(URL, xpath_query) to import data from Instagram. However, I cannot get the above query to work. – Ben Salt May 16 '18 at 07:45
  • Does this answer your question? [Scraping data to Google Sheets from a website that uses JavaScript](https://stackoverflow.com/questions/74237688/scraping-data-to-google-sheets-from-a-website-that-uses-javascript) – Rubén Jan 19 '23 at 02:18

0 Answers0