importXML解析错误 [英] importXML Parse Error

查看:149
本文介绍了importXML解析错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为otcmarkets.com上给定的一组股票解析资产负债表数据。我试图在Google Spreadsheet中使用importXML函数,但它并没有为我返回任何数据。 xPath查询没有返回任何数据。这里是我使用的函数:

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



让我知道我做错了什么,一个更好的方式来解析特定的资产负债表数据。

解决方案

页面内容使用JavaScript加载,而Google电子表格。您无法使用 = importxml(...)来分析此页面。



现在该怎么做?




  • 询问供应商是否提供API。大多数情况下,他们不希望被刮掉。

  • 分析页面逻辑并查找加载数据的JavaScript调用,然后自行获取它。最有可能的是JSON格式,在没有外部库的情况下,在Google Spreadsheets中解析并不容易。

  • 使用一些环境查询将执行JavaScript调用的数据,例如Selenium。与使用Google Spreadsheets相比,将产生更多的编程。


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.

解决方案

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.

这篇关于importXML解析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆