0

This is the error.

Google Sheet

I am trying to get a percentage from a page but say that it is empty.

This is the URL: https://www.indec.gob.ar/indec/web/Nivel3-Tema-3-5 This is the Xpath: //*[@id="content"]/div[3]/div/div[1]/div[2]

An this is the data I am looking for to get.

Content

  • I have to apologize for my poor English skill. Unfortunately, I cannot understand your expected value. Can you provide your expected value? First, I would like to correctly understand your question. – Tanaike Aug 27 '23 at 00:56
  • 1
    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) – Tedinoz Aug 27 '23 at 08:39

1 Answers1

0

IMPORTXML works fine if the data in the website is rendered in XML, HTML, CSV, TSV, and RSS and ATOM XML feeds. However some webpages uses Javascript to build it so the data can't be imported using this function.

Imported content is empty or The imported XML content can not be parsed will show as results when the XPath is not a valid HTML element so Google Sheets can’t recognize the content from it.

To check if the website you want to import data is valid HTML or it is build using script, you can disable Javascript.

  1. Open the website that you want to check.
  2. Open Chrome DevTools.
  3. Depending on your operating system, press one of the following:
  •   On Window or Linux, Control+Shift+P
    
  •   On MacOS, Command+Shift+P
    

It will open the command menu. 4. Search for Javascript and click Disable Javascript.
If you see < > with a red x icon in the address bar that means you have successfully disabled JavaScript.

  1. Reload the page. If the website load correctly, then you can import the data showing else there's no data can't be imported using the Google Sheets functions.

I also tried to fetch data from the website using UrlFetchApp.fetch() in Google Appscript however the website is build in Javascript that's why we can't fetch the data on it.

Reference:

Serenity
  • 51
  • 3
  • Feel free to ask if you have any questions with respect to the answer posted above. – Serenity Aug 28 '23 at 13:48
  • If this answers your question, please click the accept button on the left (check icon). By doing so, other people in the community, who may have the same concern as you, will know that theirs can be resolved. If the accept button is unavailable to you, feel free to tell me. [how to accept the answer](https://stackoverflow.com/help/accepted-answer) – Serenity Aug 28 '23 at 13:49