如何使用 IMPORTXML 仅导入 table 内的有限范围,而不是整个 table?

How do I use IMPORTXML to import just a limited range within a table, not the entire table?

我正在使用 Google 表格通过 IMPORTXML 功能抓取网站 table。最初的 XPath 显然只引用了 table 中的一个单元格,所以我想知道如何更改语法以仅导入第二列的前 100 行。

我试过使用 IMPORTHTML,但语法似乎更受限制。

=importxml(B4,"//*[@id='historical-data']/div/div[2]/table/tbody/tr[1:100]/td[2]")

以上代码报错如下:

"Imported XML content cannot be parsed."

[1:100] 语法不起作用。请尝试 [position()<=100]

=importxml(B4,"//*[@id='historical-data']/div/div[2]/table/tbody/tr[position()<=100]/td[2]")

也许试试这个:

=QUERY(IMPORTXML(B4, "//*[@id='historical-data']/div/div[2]/table/tbody/tr/td[2]"), 
 "limit 100", 0)

我将 IMPORTXML 换成 IMPORTHTML 以提供一个非常优雅的解决方案:

=query(importhtml(B4,"table",1),"select Col2 limit 110 offset 1",0)

感谢@player0 让我达到了 90%。