Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用谷歌网页抓取。IMPORTXML函数需要正确的xpath_Xpath_Web Scraping_Google Sheets_Google Sheets Importxml - Fatal编程技术网

使用谷歌网页抓取。IMPORTXML函数需要正确的xpath

使用谷歌网页抓取。IMPORTXML函数需要正确的xpath,xpath,web-scraping,google-sheets,google-sheets-importxml,Xpath,Web Scraping,Google Sheets,Google Sheets Importxml,有一个谷歌表单,其中包含MPN(制造商零件号)列表。当我有一个项目的MPN时,试图从一个名为wikiarms的网站上获取UPC代码 我有在另一个网站上这样做的正确公式 =IMPORTXML("http://gun.deals/search/apachesolr_search/"&B1,"//dd/a[../../dt[contains(text(),'UPC')]]|//dd/span[../../dt[contains(text(),'UPC')]]") 试图找出正确的xpath来完

有一个谷歌表单,其中包含MPN(制造商零件号)列表。当我有一个项目的MPN时,试图从一个名为wikiarms的网站上获取UPC代码

我有在另一个网站上这样做的正确公式

=IMPORTXML("http://gun.deals/search/apachesolr_search/"&B1,"//dd/a[../../dt[contains(text(),'UPC')]]|//dd/span[../../dt[contains(text(),'UPC')]]")
试图找出正确的xpath来完成此公式。我看过的一些视频说用Chrome打开页面,使用inspector选择并复制xpath来完成importxml函数。我试过了,但运气不好

样品 拜访

在表格中有一个按钮“可在6家商店购买”,单击该按钮可显示列表。UPC应列在MPN之后

如果我在Chrome中复制xpath,这就是结果

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

=IMPORTXML("https://www.wikiarms.com/guns?q="&B2,"xpath here")
我必须在这个公式的末尾添加什么才能引入UPC代码?我将使用这个公式为大约1000个项目引入UPC代码


谢谢您的帮助。

请使用示例链接,再试一次

=IMPORTXML("https://www.wikiarms.com/guns?q=20071","//td[@class='upc']/a/@title")
看看它是否对你有用