Imported content is empy Google Sheets - google-sheets

I'm trying to get the price of an item in my Sheet but I am unable to get it using IMPORTXML command as it keeps returning the error "Imported content empty"
I'm trying to retrieve the highlighted number on the image.
Site link: https://csgostash.com/sticker/3666/Battle-Scarred-Holo
My code: =IMPORTXML("https://csgostash.com/sticker/3666/Battle-Scarred-Holo","/html/body/div[3]/div[4]/div1/div/div[2]/div[2]/div1/a/span[2]")
The image is here!
It would be great if anyone could help me out, thanks!

The HTML for that website has no visual hierarchy, so it's tough to plow down through it. But this is what I arrived at:
=IMPORTXML("https://csgostash.com/sticker/3666/Battle-Scarred-Holo","/html/body/div[2]/div[4]/div/div/div/div/div[1]/a/span[2]")

Related

"Imported content is empty" error when trying to pull data using =IMPORTXML

I'm trying to pull the "Trophy points" value from https://trackmania.io/#/player/acf21a42-f517-42cc-a1b2-e8e7693da4ca using the following:
=IMPORTXML("https://trackmania.io/#/player/acf21a42-f517-42cc-a1b2-e8e7693da4ca","//*[#id='content']/div/section[2]/div/div[2]/div[2]/div[2]/table/tr[1]/td")
When I try this, the cell returns "#N/A" and when I hover "Imported content is empty". The only reason I can think of is that the data on the website hasn't loaded by the time Sheets attempts to pull the data, so it returns with no value.
your assumption of the not-loaded site is incorrect. the issue is the website itself that uses JavaScript. IMPORT formulae of google sheets does not support scrapping of JS elements. any such attempt will lead to #N/A error and imported content will be empty. you can always check this by doing:

ImportXML not returning entire table

I cannot get an entire table to populate with ImportXML. At best I get the first column and I cannot figure this out.
The website I am trying to scrape is: https://classic.warcraftlogs.com/character/us/kromcrush/chills
Do I have any options to retrieve the table rather it be column by column or as a whole?
I have tried all the following plus several others.
=IMPORTXML("https://classic.warcraftlogs.com/character/us/kromcrush/chills","//table[#id='boss-table-1010']/tbody/tr")
=IMPORTXML("https://classic.warcraftlogs.com/character/us/kromcrush/chills","//tbody/tr")
=IMPORTXML("https://classic.warcraftlogs.com/character/us/kromcrush/chills","//tbody/tr/td")
=IMPORTXML("https://classic.warcraftlogs.com/character/us/kromcrush/chills","//tr")
=IMPORTXML("https://classic.warcraftlogs.com/character/us/kromcrush/chills","//tr/td")
=IMPORTXML("https://classic.warcraftlogs.com/character/us/kromcrush/chills","//tr/td[1]")
=IMPORTXML("https://classic.warcraftlogs.com/character/us/kromcrush/chills","//tr/td[2]")
Anything outside of column one says Imported content is empty. Please help!
P.S. I have scoured this website and google for answers and every case I find seems to be a syntax error, starting at the table itself doesn't return the entire table which tells me I need a clever method.
It seems that's an issue with the website, because when you click on Inspect you can see the table with id "boss-table-1010" but if you click on View Source that ID is not available, so the table is dynamically rendered and Sheets doesn't find such id.
I've checked it and I can get the data by doing
=IMPORTXML("https://classic.warcraftlogs.com/character/us/kromcrush/chills", "//table/tbody//td")
But if you want a more robust solution, it'll be better doing it programmatically by using Python for web scraping

Google Spreadsheets ImportXML / XPath - I get "data:image/svg+xml..."

I am trying to get the url of the images from web link.
For this I use the IMPORTXML and XPATH function in google Spreadsheet.
This is the code:
=IMPORTXML(B1;"//*[#id='gallery-1']/figure/div/a//img/#src")
So far everything is correct, get the urls of each image, however, I am also getting the following text in turn for each URL obtained.
data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20500%20400'%3E%3C/svg%3E
I don't know how to prevent this text from appearing. I have been looking at the source code of the page link and this text does not appear anywhere. Therefore I consider that it is something related to spreadsheet.
I have checked the xpath again and again but I also find that there is an error ...
Here is a screenshot of what happened for your reference.
https://drive.google.com/file/d/1Tv_zk0JUI9EjCTU0kKfzRuQr936-88I7/view?usp=sharing
Any help is greatly appreciated. Thanks
try:
=QUERY(IMPORTXML(B1, "//*[#id='gallery-1']/figure/div/a//img/#src"),
"where not Col1 starts with 'data'")

How to import get Exchange code from FINVIZ using importxml, when referencing stock code from a google sheet cell

I am unable to get Exchange name NYSE using =SUBSTITUTE(substitute(importxml(D4,H1),"[",""),"]",""), I receive error message "Resource at url not found". Url in D4 is https://finviz.com/quote.ashx?t="&C12, Xpath in H1 is //span[#class='body-table']. However when I change the url to https://finviz.com/quote.ashx?t=A, it correctly display NYSE.
Am I using the correct formula when referencing a cell as part of the url (ie "&C12), or are websites now restricting you from referencing tickers in cell, as this used to work before. I also checked on Marketwatch which is also rejecting this function with an error message of "Imported content is empty".
try:
=REGEXREPLACE(IMPORTXML("https://finviz.com/quote.ashx?t="&A1,
"//span[#class='body-table']"), "[\[\]]", )
Thanks for the regreplace solution, actually all with and without regreplace or substitute are now working again, as they were previously, on both Finviz and Marketwatch. I guess it was just an internet glitch caused by the downtime a couple of days ago. Thanks for the quick reply. This question can now be closed.

Getting “#N/A” error when using importhtml formula

I was trying to import a table from hket website to run some analysis of my own.
When I used: =importxml("http://www1.hket.com/finance/chart/industry-index.do","//*[#id='eti-finance-chart-table']") which represents the link to the site, I am getting the "N/A" error.
The importxml works fine with gurufocus site.
Can you help me out? I haven't been able to figure out what the issue could be.
from what I understand, hket doesn't use HTML or XML format for their table. If that is the case, is there a script I can use in Google Sheets that will let me extract data from hket?
you can see the culprit if you run this formula:
=IMPORTXML("http://www1.hket.com/finance/chart/industry-index.do", "//*")

Resources