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
使用XPath包含_Xpath - Fatal编程技术网

使用XPath包含

使用XPath包含,xpath,Xpath,我试图从各种网站上搜集价格数据。除了一个网站,每个产品页面的价格XPath都是唯一的,例如 第A页-/*[@id=“price-include-tax-2940”] 第B页-/*[@id=“price-include-tax-1456”] i、 它们都有一个唯一的编号作为查询字符串的一部分 这是其中一页的示例 为了避免在每个页面上查找唯一的XPath for price,我尝试修改XPath查询以删除唯一的编号。我已经尝试了各种方法,/*[id=[contains(,'price-include

我试图从各种网站上搜集价格数据。除了一个网站,每个产品页面的价格XPath都是唯一的,例如
第A页-
/*[@id=“price-include-tax-2940”]

第B页-
/*[@id=“price-include-tax-1456”]

i、 它们都有一个唯一的编号作为查询字符串的一部分

这是其中一页的示例


为了避免在每个页面上查找唯一的XPath for price,我尝试修改XPath查询以删除唯一的编号。我已经尝试了各种方法,
/*[id=[contains(,'price-include')]
但是我对XPath的理解不足让我失望。

对我来说,你似乎想要

//*[contains(@id,'price-including')]

您需要确保
contains
函数对
id
属性的值进行操作,方法如下:

//*[contains(@id, "price-including")]