Unable to pull data from importhtml function in google sheets - google-sheets

I used the following two formulas to get data from the related query table/list of the Google Trends webpage but it doesn't give any result. Any idea why? and how can I get this to work? Thanks
=importhtml("https://trends.google.com/trends/explore?date=now%207-d&q=bob", "list", 1)
=importhtml("https://trends.google.com/trends/explore?date=now%207-d&q=bob", "table", 1)

Related

How do you use IMPORTXML correctly?

I just started using ImportXML in Google sheets, although I have been successfully using it several times, this time I can't figure out what is going wrong:
I want to scrape the monthly visitors of a website through similarweb. Here is an example URL:
https://www.similarweb.com/website/autohuset-vestergaard.dk/#overview
Copying the Xpath results in:
//*[#id="overview"]/div/div/div/div[5]/div/div[1]/p[2]
The formula I'm using is:
=IMPORTXML("https://www.similarweb.com/website/autohuset-vestergaard.dk/#overview";"//*[#id='overview']//div/div/div/div[5]/div/div[1]/p[2]")
And I get a #N/A error
Any ideas? Thanks!

Google Sheets ImportXML Split Definitions

I made a Google Sheets Dictionary for my ESL students. My issue is when the sheet is pulling multiple definitions. I would like it to only pull the first/top definition from the site. I know there is a way to fix this but can't seem to figure it out.
=IFERROR(INDEX(SPLIT(CONCATENATE(IMPORTXML("https://www.learnersdictionary.com/definition/"&A4,"//span[#class='def_text']")),":",FALSE,TRUE),1,1))
try:
=IMPORTXML("https://www.learnersdictionary.com/definition/"&A4,
"//ul[#class='o_list verdana_font']")
update:
=IMPORTXML("https://www.learnersdictionary.com/definition/"&A4,
"//span[#class='def_text']")
or if you want just first one try:
=INDEX(IMPORTXML("https://www.learnersdictionary.com/definition/"&A4,
"//span[#class='def_text']"), 1, 1)

Importing table values from yahoo finance using the IMPORTHTML function in Google Sheets

The following function in Google Sheets worked until last Friday:
=index(IMPORTHTML("https://finance.yahoo.com/quote/"&B1&"/key-statistics?p="&B1&"","table",
2),5,2)
This function would go to the statistics section in Yahoo Finance and extract the Market Cap from a stock. It stopped working today and I'm not sure why.
I tried using the following command in the Chrome console to get the table number and played with the table indices for the IMPORTHTML function but no luck:
var i = 1; [].forEach.call(document.getElementsByTagName("table"),
function(x) { console.log(i++, x); });
Did Yahoo do something to make this no longer work? OR are my indices just wrong now?
I tried using every IMPORT formula of Google Sheets and unfortunately, it is returning the same error every single time.
It seems that Yahoo changed some things in their website and it resulted to the import formula not to work anymore.
I suggest finding another website/data source that will give you the same information that you need. Or if you want to stay with Yahoo Finance, you can explore and try to use their API if you want (link-here).
EDIT: Upon further checking, it seems that this issue is only happening on some of the tickers and some webpage in Yahoo Finance. Another option would be waiting for Yahoo to fix the issue.

ImportXML Function on Google Sheets

I'm having a tough time pulling info in on Google Sheets using the ImportXML function. I want to pull in the price of a crypto coin so that I have a real-time feed. The link that I'm hoping to pull from is:
https://www.dextools.io/app/uniswap/pair-explorer/0x40f0e70a7d565985b967bcdb0ba5801994fc2e80
I've tried out a lot of different formulas and keep getting an #N/A or an error. Some of the ones I've tried:
Copy XPATH fully:
=IMPORTXML("https://www.dextools.io/app/uniswap/pair-explorer/0x40f0e70a7d565985b967bcdb0ba5801994fc2e80","/html/body/app-root/div[3]/div/main/app-uniswap/div/app-pairexplorer/app-layout/div/div/div[2]/div[2]/ul/li[2]/span")
Shortened XPATH (also tried deleting the second backslash before 'li' but that didn't work):
=IMPORTXML("https://www.dextools.io/app/uniswap/pair-explorer/0x40f0e70a7d565985b967bcdb0ba5801994fc2e80","//li[2]/span")
Include class:
=IMPORTXML("https://www.dextools.io/app/uniswap/pair-explorer/0x40f0e70a7d565985b967bcdb0ba5801994fc2e80","//li[2]/span[#class='ng-tns-c93-2 ng-star-inserted']")
Does anyone have thoughts? Thanks!
upon disabling JavaScript the site is empty = can't be scraped by Google Sheets by any import formula.
To avoid the problem above, consider using a proper API service that gives you easy access to the data.
For instance you could get Zero price in USD using
=IMPORTDATA("https://cryptoprices.cc/ZERO/")
If you need it in comparison to ETH you could try doing it by hand
=IMPORTDATA("https://cryptoprices.cc/ZERO/")/=IMPORTDATA("https://cryptoprices.cc/ETH/")
Or use a more advanced API such as CoinGecko's
https://www.coingecko.com/en/api

Adding a blank row in importhtml query in Google Sheets

I'm trying to import some Spotify stats from a table on a site into Google Sheets. I was wondering if it's possible to insert a blank row before the total for each artist, and if it's possible to make it bold? I'm currently using basic queries like this:
=QUERY(IMPORTHTML("https://chartmasters.org/spotify-streaming-numbers-tool/?artist_name=&artist_id=25pbZ2yTnog5SBbk7WyfNn&displayView=Disco", "table", 1),"select Col2,Col1,Col3 offset 1",0)
Thank you for any help.

Resources