Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k views
in Technique[技术] by (71.8m points)

bitcoin - Using importXML results in "Imported Content is Empty" error on Google Spreadsheets

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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")

enter image description here

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...