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
868 views
in Technique[技术] by (71.8m points)

parsing - importXML Parse Error

I need to parse balance sheet data for a given set of stocks on otcmarkets.com. I'm trying to use the importXML function in Google Spreadsheet, but it is not returning any data for me. The xPath query did not return any data. Here is the function I'm using:

=importxml("http://www.otcmarkets.com/stock/AAEH/financials","//*[@id=’totalCurrentLiabilities’]")

Let me know what I'm doing wrong and if there is a better way to parse specific balance sheet data.

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

The page contents are loaded using JavaScript, which is not executed in Google Spreadsheets. You cannot parse this page using =importxml(...).

What to do now?

  • Ask the providers if they offer an API. Most probably they don't want to be scraped anyway.
  • Analyze the page logic and find the JavaScript call which loads the data, and fetch it yourself. Most probably it is in JSON format, which is not easy to parse in Google Spreadsheets without external libraries.
  • Use some environment to query the data which will execute the JavaScript calls, for example Selenium. Will result in much more programming than using Google Spreadsheets.

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

...