Google工作表importxml失败 - 无法从链接中找到表的正确路径

时间:2018-05-24 22:03:38

标签: html xml xpath google-sheets

我正在尝试检索每天更新两次的表。在其他网站上,我能够找到该元素,但我看到我看到的方式在我试过的所有网站上都不起作用。

在这种情况下,问题是: 在使用 importxml google sheet 中,我无法从链接中找到正确的表格路径或标识该元素。

此示例的网站是:http://lotopolonia.com/tabel/arhiva/index.php

1。我需要检索日期和数字。

2。它们每天更新两次,并在我的工作表中进行更新,只添加其他页面顶部的最后一行。但是在我解决了第一个之后这个。

我查看了w3c的xpath教程,并对语法有所了解。 问题是如何正确识别检查器中的元素和节点以检索我需要的数据。

另外,我安装了一个chrome扩展程序(XPath Helper),它显示的xpath比我从chrome获得的更好。

我尝试了以下内容:

=IMPORTXML("http://lotopolonia.com/tabel/arhiva/index.php","//table[@class='table_01']/tbody/tr[@class='second_row']/td[@class='colon2']")

=IMPORTXML("http://lotopolonia.com/tabel/arhiva/index.php","//table[@class='table_01']/tbody/tr[@class='second_row']/td[*]")

=IMPORTXML("http://lotopolonia.com/tabel/arhiva/index.php","//table[@class='table_01']/tbody/tr[@class='first_row'][1]/td[*]")

=IMPORTXML("http://lotopolonia.com/tabel/arhiva/index.php","//*[@class='table_01']/table/tbody/tr[@class='first_row'][1]/td[*]")

=IMPORTXML("http://lotopolonia.com/tabel/arhiva/index.php","//table[@class='table_01']/tbody/tr[3]/td[*]")

=IMPORTXML("http://lotopolonia.com/tabel/arhiva/index.php","//table[@class='table_01']/tbody/tr[*]/td[*]")

=IMPORTXML("http://lotopolonia.com/tabel/arhiva/index.php","//table[@class='table_01']/tbody/tr[@class='second_row'][1]/child::td[*]")

该公式看起来没问题,没有错误,但在以上所有请求中我都得到相同的结果: 导入的内容为空

不幸的是,我没有想法以及如何解释这些元素......

任何想法如何继续?

干杯

1 个答案:

答案 0 :(得分:1)

这个答案怎么样?我使用//table[@class='table_01']/tr[position()>2]作为xpath。 “A1”有http://lotopolonia.com/tabel/arhiva/index.php

=IMPORTXML(A1,"//table[@class='table_01']/tr[position()>2]")
  • 使用table[@class='table_01']检索表格。
  • 使用tr[position()>2],检索日期和数字。

结果:

enter image description here

注意:

  • 如果您想要检索整个表格,请使用=IMPORTXML(A1,"//table[@class='table_01']/tr")

如果这不是你想要的,我很抱歉。