首页 > 解决方案 > 无法在 googlesheet 中找到要导入的正确 xpath

问题描述

我试图通过使用 importxml 来获取数据,但我很想获取我使用的数据 XPath 没有提供我想要获取的数据。但我可以使用 importhtm 和提表获得相同的数据,但我需要使用 importxml 来获得最佳匹配。

这是我使用检查元素工具获得的 XPath

/html/body/div[2]/div[1]/div[1]/table/tbody/tr[1]/td[2]/strong

这是CSS路径

 div.container-fluid div.row-fluid div.span6 table.table.table-bordered tbody tr td strong

这是 CSS 选择器

div.span6:nth-child(1) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2) > strong:nth-child(1)

我尝试过的

=ImportXML("https://siteurl com","//*[@class='span6']/table/tbody/tr[1]/td[2]/strong")

Got Error #N/A  (Error
Imported content is empty.)

标签: xpathweb-scrapinggoogle-sheetsgoogle-sheets-formulagoogle-sheets-importxml

解决方案


尝试:

=SUBSTITUTE(INDEX(IMPORTHTML(B10, "table", 1), 1, 2), "*", )*1

其中 B10 是您的网址

0


推荐阅读