Google Sheets importxml 中 XPath 中的多个索引

Multiple indexes in XPath in Google Sheets importxml

我正在将 Bloomberg 的一些数据用于 Google 电子表格,其中两行读作:

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

但是总体上importxmlimporthtml的数量很多,而且很多都在查询同一个网页。结果,太多的细胞处于永恒的 "Loading..." 状态。 Google甚至显示消息:

"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]",但这显然 returns 是一个错误。

这样试一下,看看行不行:

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

在您的 XPath 之间使用 |,例如:

=IMPORTXML("https://www.bloomberg.com/quote/ELIPCAM:BZ", 
 "(//span)[28] | (//span)[31]")