Using importXML results in “Imported Content is Empty” error on Google Spreadsheets

无人久伴 提交于 2019-12-24 20:40:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!