Search code examples
google-sheetsgoogle-sheets-formulaimporterror

Google Sheets ImportXML - Error: "Imported content is empty."


I am trying to import the table of following website: https://spaclens.com/index.html#/company/list

As far as I can see it is a HTML Table with the contents actually inside and not loading externally.

However,

=importxml("https://spaclens.com/index.html#/company/list","//*[@id='app']/div/div/div/div[1]/div/div[2]/div/div[2]/div/div[3]/table/tbody")

returns #N/A

=importxml("https://spaclens.com/index.html#/company/list","//div[@id='app']")

returns "SPACLensLoading..." as plain text

Can anyone explain why it is not working?

Many thanks!


Solution

  • The website you are trying to is controlled by JavaScript, thus, making it unable for Google Sheets to fetch the data using IMPORT functions.

    You can check if a website is JavaScript controlled by clicking on the lock icon beside the address bar -> site settings -> set JavaScript to 'Block'. Reload the page and if you don't see the data you are trying to fetch, then Google Sheets won't be able to get it.

    See screenshots below for what happened to the website after turning JavaScript to 'Block':

    enter image description here

    I suggest finding another website that gives you the same data and use it instead.