python修改xpath节点_Xpath python在特定文本后查找节点
生活随笔
收集整理的這篇文章主要介紹了
python修改xpath节点_Xpath python在特定文本后查找节点
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
這里是HTML代碼:
Specific text 1
link1 inside specific text 1
link2 inside specific text 1
link3 inside specific text 1
Specific text 2
link1 inside specific text 2
link2 inside specific text 2
link3 inside specific text 2
link4 inside specific text 2
Specific text 3
link1 inside specific text 3
link2 inside specific text 3
我必須明確地在每個“特定文本”下找到鏈接。問題是,如果我在python中編寫下面的代碼:links = root.xpath("//div[@id='someid']//a")
for link in links:
print link.attrib['href']它打印所有鏈接,而不考慮“特定文本x”,而我想要的東西如:
print "link under Specific text:"+specific+" link:"+link.attrib['href']請建議
總結
以上是生活随笔為你收集整理的python修改xpath节点_Xpath python在特定文本后查找节点的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle数据库重建em,oracle
- 下一篇: android animatorset