你好,我有这个HTML:
<div class="_3Vhpd"><span>Your commerce Data</span>
<a class="n3G0C" href='http://www.webadress.......'><span>Some Text</span</a>
</div>
我试图按如下方式获取标签:
parser.xpath('//div[contains(@class,"_3Vhpd")]//following-sibling::*[a[@class="n3G0C"]]/@href ')
但是我没有收到“ []”。也许是因为不仅在div之后,而且在跨度之后...
答案 0 :(得分:0)
首先,您示例的html没有class="n3G0C"
,但是假设您对其进行了修复,则此xpath表达式应该可以工作:
//div[contains(@class,"_3Vhpd")]//following-sibling::a/@href
输出:
http://www.webadress .......