importXML 解析错误 [英] importXML Parse Error

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

问题描述

我需要解析 otcmarkets.com 上一组给定股票的资产负债表数据.我正在尝试在 Google 电子表格中使用 importXML 函数,但它没有为我返回任何数据.xPath 查询未返回任何数据.这是我正在使用的功能:

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.

推荐答案

页面内容使用 JavaScript 加载,不会在 Google 电子表格中执行.您无法使用 =importxml(...) 解析此页面.

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

现在该怎么办?

  • 询问提供商是否提供 API.无论如何,他们很可能不想被刮掉.
  • 分析页面逻辑,找到加载数据的 JavaScript 调用,并自行获取.很可能是 JSON 格式,如果没有外部库,在 Google 电子表格中不容易解析.
  • 使用一些环境来查询将执行 JavaScript 调用的数据,例如 Selenium.与使用 Google 电子表格相比,将产生更多的编程.

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

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