因此,我希望使用xpath从<;p>;获取href标记。在
我想使用文本来自<;h1>;标签('Cable Stripe Knit L/S Polo') 同时从<;p>;标记('White')中查找<;p>;标记中的href
一。 . 在
注意:一个项目有更多的颜色(更多的文章具有不同的<;p>;标签,但<;h1>;标签相同)!在
Html Source
<article>
<div class="inner-article">
<a href="/shop/tops-sweaters/ix4leuczr/a1ykz7f2b" style="height:150px;">
</a>
<h1>
<a href="/shop/tops-sweaters/ix4leuczr/a1ykz7f2b" class="name-link">Cable Stripe Knit L/S Polo
</a>
</h1>
<p>
<a href="/shop/tops-sweaters/ix4leuczr/a1ykz7f2b" class="name-link">White</a>
</p>
</div>
</article>
^{pr2}$I've tried this code but it doesn't work
Much thanks for your response!
一。在
一。在
根据html源代码,用于获取href标记的xpath如下所示:
因为有2个超链接标记,所以应该使用find_elements_by_xpath,它返回元素列表。在本例中,它将返回2个超链接标记,您可以使用get_attribute方法获取它们的href。在
相关问题 更多 >
编程相关推荐