我正在努力处理Google Sheets IMPORTXML函数中的XPath查询。我想从this site那里弄到一张桌子。显然,只使用//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扩展测试了这个查询,它给了我想要的结果。但不幸的是,表格没有显示在我的电子表格中。
发布于 2019-02-15 22:26:47
只有这些表可以抓取:
=IMPORTHTML("https://us.soccerway.com/national/england/premier-league/20182019/regular-season/r48730/",
"TABLE", 2)
其他任何东西都是不受限制的,因为它是由JavaScript控制的。如果您单击锁定并输入设置并禁用JS并重新加载页面,则可以进行检查。然后你可以观察到点击Form
按钮什么也不做-例如。不能被刮掉。
https://stackoverflow.com/questions/54717727
复制相似问题