我正在将 Bloomberg 的一些数据输入到 Google 电子表格中,其中两行内容如下:
=importxml("https://www.bloomberg.com/quote/ELIPCAM:BZ";"(//span)[28]")
=importxml("https://www.bloomberg.com/quote/ELIPCAM:BZ";"(//span)[31]")
但是,总体上存在大量的 importxml
和 importhtml
,并且其中许多查询同一网页。结果,太多的单元格永远处于“正在加载...”状态。谷歌甚至给出了这样的信息:
"Loading data may take a while because of the large number of requests. Try to reduce the amount of IMPORTHTML, IMPORTDATA, IMPORTFEED or IMPORTXML functions across spreadsheets you've created."
那么,有什么办法可以合并上面的请求吗?当然,我可以打开一个新选项卡并导入所有内容(即仅使用 "(//span)"
进行查询),但除了困惑之外,我担心我仍然会查询比我需要的更多。理想情况下,应该对多个编号节点进行一些查询,例如 "(//span)[28,31]"
,但这显然会返回错误。
最佳答案
尝试一下这个方法,看看是否有效:
=importxml("https://www.bloomberg.com/quote/ELIPCAM:BZ","(//span)[position()=28 or position()=31]")
关于xpath - Google Sheets importxml 中 XPath 中的多个索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59259697/