Google Sheets has several import functions
- IMPORTDATA
- IMPORTFEED
- IMPORTHTML
- IMPORTXML
Sometimes the above functions returns errors like #N/A Imported content is empty
and would like to be sure that there isn't a problem with the resource content to be imported.
How do I know if these functions are able to get the content that I looking to import?
I know that there also exist IMPORTRANGE but that function only is able to import content from Google Sheets spreadsheets
Best Answer
Tl;Dr
If the content is added dynamically (by using Javascript), it can't be imported by using Google Sheets built-in functions. Also if the website webmaster have taken certain measures, this functions will not able to import the data.
Content added dynamically
To check if the content is added dynamically, using Chrome,
javascript
, select Disable JavaScript, and then press Enter to run the command. JavaScript is now disabled.JavaScript will remain disabled in this tab so long as you have DevTools open.
Reload the page to see if the content that you want to import is shown, if it's shown it could be imported by using Google Sheets built-in functions, otherwise it's not possible but might be possible by using other means for doing web scraping.
Use of robots.txt to block webcrawlers
The webmasters could use robots.txt file to block access to website. In such case the result will be
#N/A Could not fetch url
.Use of User agent
The webpage could be designed to return a special a custom message instead of the data.
IMPORTDATA, IMPORTFEED, IMPORTHTML and IMPORTXML are able to get content from resources hosted on websites that are:
csv
ortsv
doesn't matter of the file extension of the resource.On W3C Markup Validator there are several tools to checkout is the resources had been properly marked up.
Regarding CSV check out Are there known services to validate CSV files
It's worth to note that the spreadsheet
References
Related
The following question is about a different result,
#N/A Could not fetch url