2

我在 Google Sheets IMPORTXML 函数中的 XPath 查询中苦苦挣扎。我正在尝试从该站点获取表格。使用 only//tr显然给了我网站上的所有表格行。因为我想要一个特定的表,所以我需要表 id 来钻取结果。

表id(和类)如下:



<table class="leaguetable sortable table detailed-table fixed-wide-table" id="page_competition_1_block_competition_tables_7_block_competition_form_table_1_table">


在此处查看我当前的功能和查询。



=IMPORTXML("https://us.soccerway.com/national/england/premier-league/20182019/regular-season/r48730/","//table[@id='page_competition_1_block_competition_tables_7_block_competition_form_table_1_table']/tr")


在电子表格中使用这个公式会给我#N/A和错误消息Imported content is empty

我使用 Chrome 扩展程序测试了查询,它给了我想要的结果。但不幸的是,该表格没有出现在我的电子表格中。

4

1 回答 1

1

只有这些表你可以刮:

=IMPORTHTML("https://us.soccerway.com/national/england/premier-league/20182019/regular-season/r48730/", 
 "TABLE", 2)

其他任何东西都超出了限制,因为它是由 JavaScript 控制的。如果您单击锁定并输入设置并禁用 JS 并重新加载页面,您可以进行检查。然后你可以观察到点击Form按钮什么都不做 - 例如。不能刮。

于 2019-02-15T22:26:47.073 回答