我是一个编程初学者,我的一个朋友告诉我使用beauthoulsoup而不是htmlparser。遇到一些问题后,我得到了一个建议,用lxml代替BeaytifulSoup,因为它比BeaytifulSoup好10倍。在
我希望有人能给我一个提示,如何擦掉我要找的文本。在
我想要的是找到一个包含以下行和数据的表:
<tr>
<td><a href="website1.com">website1</a></td>
<td>info1</td>
<td>info2</td>
<td><a href="spam1.com">spam1</a></td>
</tr>
<tr>
<td><a href="website2.com">website2</a></td>
<td>info1</td>
<td>info2</td>
<td><a href="spam2.com">spam2</a></td>
</tr>
我如何使用lxml
在没有垃圾邮件的情况下,用信息1和信息2抓取网站并得到以下结果?在
长XPath具有以下含义:
^{pr2}$结果:
^{pr2}$我使用xpath:
td/a[not(contains(.,"spam"))]/@href | td[not(a)]/text()
相关问题 更多 >
编程相关推荐