我试图刮掉以下网站:http://www.hudson211.org/zf/profile/service/id/659837
我正在尝试选择"网址"文本旁边的href.以下xpath选择器获取我之后的标记:
$x("//th[contains(text(), 'Web Address')]/following-sibling::td/a")
Run Code Online (Sandbox Code Playgroud)
回报
<a href="http://www.co.sullivan.ny.us">www.co.sullivan.ny.us</a>
Run Code Online (Sandbox Code Playgroud)
但是,当我专门尝试使用@href提取href时,返回值是一个空数组:
$x("//th[contains(text(), 'Web Address')]/following-sibling::td/a/@href")
Run Code Online (Sandbox Code Playgroud)
回报 []
这是我正在查看的行的html:
<tr valign="top">
<td class="profile_view_left"></td>
<th align="left" class="profile_view_center">Web Address</th>
<td class="profile_view_right">
<ahref="http://www.co.sullivan.ny.us">www.co.sullivan.ny.us</a> </td>
<td></td>
</tr>
Run Code Online (Sandbox Code Playgroud)