2

I have a google sheet in which I am some Cryptocurrencies Price Data that I get using googleFinance or yahoo. However, I found it difficult to do this with some coins such as Synthetix Network Token.

I have been reading other questions in Stackoverflow and applying the suggestions but none seem to work with this particular cryptocurrency.

If there is someone who has done this before, could you tell me what approach are you using?

Update:

I have tried this:


=GOOGLEFINANCE("SNXGBP")

And also this

=INDEX(IMPORTXML("https://finance.yahoo.com/quote/SNX-GBP/","//div[@data-reactid='32']"), 2, 1)

Both work with the majority of cryptocurrencies.

player0
  • 124,011
  • 12
  • 67
  • 124

2 Answers2

6

I would suggest using a proper service instead of scraping web pages.

The parsing is just gonna fail eventually and force you to rewrite

=IMPORTDATA("https://cryptoprices.cc/SNX/")*GOOGLEFINANCE("CURRENCY:USDGBP")

This request will give you all the price of SNX coin in GBP (using Google Sheets native function to convert USD to GBP)

Pedro
  • 416
  • 1
  • 8
  • 24
  • This doesn't work for numbers with leading zero's such as "0.354". It's turned into "354". I've tried by importing with importXML with tag "//body" but it's stuck on loading ... I've currently solved it like this: ****=value(text(ImportXML("cryptoprices-link";".";"en_US");"000000.000000"))**** And it works quite well, though there might be better solutions? – Rakward Nov 22 '21 at 10:24
4

try:

=IMPORTXML("https://coinmarketcap.com/currencies/synthetix-network-token/", 
 "//div[@class='priceValue___11gHJ']")

enter image description here


or:

=SUBSTITUTE(IMPORTXML("https://coinmarketcap.com/currencies/synthetix-network-token/", 
 "//div[@class='priceValue___11gHJ']"), "$", )*GOOGLEFINANCE("CURRENCY:USDGBP")

enter image description here

player0
  • 124,011
  • 12
  • 67
  • 124
  • 1
    Both worked!! Many thanks. And also with other coins. Thnaks – Manolo Dominguez Becerra Feb 08 '21 at 16:03
  • Hi player0, Your code worked but most of the time for a reason I cant underdtand google sheet report this Could not fetch URL: https://coinmarketcap.com/currencies/synthetix-network-token/. So most of the time is not working. I am living in UK and I have notice that, same url is different depending on the country you are. – Manolo Dominguez Becerra Feb 10 '21 at 09:57
  • you can try to add switch(es) so if import fails it tries again: `=IFERROR(IMPORTXML("https://coinmarketcap.com/currencies/synthetix-network-token/", "//div[@class='priceValue___11gHJ']"), IMPORTXML("https://coinmarketcap.com/currencies/synthetix-network-token/", "//div[@class='priceValue___11gHJ']"))` – player0 Feb 10 '21 at 10:07
  • Both are working now. I will inform you about the results. Many thanks anyway. – Manolo Dominguez Becerra Feb 10 '21 at 23:25
  • 1
    I'm getting the error: "Imported content is empty" from: "=IMPORTXML("https://coinmarketcap.com/currencies/ethereum/","//div[@class='priceValue___11gHJ']")" – RkuangDev Jul 10 '21 at 06:09
  • I noted you can get it also from class - 'priceValue smaller price' seems like priceValue with static div is updated. and not yet works. `=IMPORTXML("https://coinmarketcap.com/currencies/saitama-inu/","//div[@class='priceValue smallerPrice']")` – Ido Bleicher Jan 24 '22 at 23:49