xpath - Google Sheets importxml 中 XPath 中的多个索引

标签 xpath web-scraping google-sheets google-sheets-formula

我正在将 Bloomberg 的一些数据输入到 Google 电子表格中,其中两行内容如下:

=importxml("https://www.bloomberg.com/quote/ELIPCAM:BZ";"(//span)[28]")
=importxml("https://www.bloomberg.com/quote/ELIPCAM:BZ";"(//span)[31]")

但是,总体上存在大量的 importxmlimporthtml,并且其中许多查询同一网页。结果,太多的单元格永远处于“正在加载...”状态。谷歌甚至给出了这样的信息:

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

相关文章:

google-apps-script - 谷歌表格 setUnderline (offsetBegin, offsetEnd)

perl - 使用XML::LibXML打印输出

javascript - 如何从 Xpath 中的 javascript 事件处理程序获取链接?

python-2.7 - python lxml xpath没有输出

javascript - 将类添加到包含 innerHTML 字符串的 div

python - 当我在 selenium 中使用 Click() 时,页面中的动态元素(表)不会更新,因此我无法检索新数据

python - beautifulsoup 4 : Segmentation fault (core dumped)

python - 使用 Selenium 在 Python 中抓取由 javascript 注入(inject)的图像

google-sheets - 如何使用 Google 电子表格上的公式复制字符串并附加数字后缀?

javascript - 在 Zapier 代码上使用外部 javascript 库或 SDK