问题
What I'm trying to do:
Dynamically import the bitcoin/BTC price, from https://www.luno.com/en/price/, OR https://www.luno.com/en/price/BTC.
So I've read everything there is to read (on this site anyway) about importXML
, and cannot find what I'm doing wrong. My method works on other websites, where I get a list of expected results, however, using importXML
is not working. See below code I'm using (I've used other variants, but this is the one suggested using SelectorGadget
:
=IMPORTXML("https://www.luno.com/en/price/", "//*[contains(concat( ' ', @class, ' ' ), concat( ' ', 'ng-binding', ' ' ))]")
Of course, I get the dreaded " Imported Content is Empty " error.
Any help?
回答1:
You can load this ajax endpoint to get the current USD:
https://www.luno.com/ajax/1/display_ticker
or for all currency pairs:
https://www.luno.com/ajax/1/price_chart?currency=
if your want to parse the json - there is a wonderful - already written importJson script (https://github.com/bradjasper/ImportJSON/blob/master/ImportJSON.gs), you literally just copy paste it into your apps script and then call the url directly as such:
=importJSON("https://www.luno.com/ajax/1/price_chart?currency=")
or
=importJSON("https://www.luno.com/ajax/1/display_ticker?currency=XBT")
来源:https://stackoverflow.com/questions/47674721/using-importxml-results-in-imported-content-is-empty-error-on-google-spreadshe