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_Crawler4j_Import.io - Fatal编程技术网

用于爬网的XPath跟随同级而不返回同级

用于爬网的XPath跟随同级而不返回同级,xpath,crawler4j,import.io,Xpath,Crawler4j,Import.io,我正在尝试创建一个爬虫程序,从供应商网站中提取一些属性数据,我可以根据我们的内部属性数据库进行审计,并且是import.io的新手。我看了很多视频,但尽管我的语法似乎正确,但我的手动xpath覆盖并没有返回属性值。我有以下示例html代码: <table> <tbody><tr class="oddRow"> <td class="label">&nbsp;Adhesive Type&lrm;</td><td>

我正在尝试创建一个爬虫程序,从供应商网站中提取一些属性数据,我可以根据我们的内部属性数据库进行审计,并且是import.io的新手。我看了很多视频,但尽管我的语法似乎正确,但我的手动xpath覆盖并没有返回属性值。我有以下示例html代码:

<table>
<tbody><tr class="oddRow">
<td class="label">&nbsp;Adhesive Type&lrm;</td><td>&nbsp;Epoxy&lrm;
</td>
</tr>
<tr>
<td class="label">&nbsp;Applications&lrm;</td><td>&nbsp;Hard Disk Drive Component Assembly&lrm;
</td>
</tr>
<tr class="oddRow">
<td class="label">&nbsp;Brand&lrm;</td><td>&nbsp;Scotch-Weld&lrm;
</td>
</tr>
<tr>
<td class="label">&nbsp;Capabilities&lrm;</td><td>&nbsp;Sustainability&lrm;
</td>
</tr>
<tr class="oddRow">
<td class="label">&nbsp;Color&lrm;</td><td>&nbsp;Clear Amber&lrm;
</td>
我尝试使用:

//*[@id="attributeList"]/table/tbody/tr/td[.="Color"]/following-sibling::td

但它并没有从表中获取颜色属性值。我不确定这是否与奇偶行类有关?当我看html时,它似乎是合乎逻辑的;颜色是“颜色”,属性值在下面的td括号中。

所选的
td
节点中的文本不仅仅包含
“颜色”
。它是
Color&lrm。因此,您可以选择
td
节点,这些节点的文本字符串
“Color”

//*[@id="attributeList"]/table/tbody/tr/td[.="Color"]/following-sibling::td
'//*[@id="attributeList"]/table/tbody/tr/td[contains(text(), "Color")]/following-sibling::td/text()'