私はこのxpathクエリを持っています:
/html/body//tbody/tr[*]/td[*]/a[@title]/@href
title 属性を持つすべてのリンクを抽出し、href
FireFoxの Xpath チェッカー アドオン を提供します。
しかし、私はそれを使用することはできませんlxml
。
from lxml import etree
parsedPage = etree.HTML(page) # Create parse tree from valid page.
# Xpath query
hyperlinks = parsedPage.xpath("/html/body//tbody/tr[*]/td[*]/a[@title]/@href")
for x in hyperlinks:
print x # Print links in <a> tags, containing the title attribute
これはlxml
(空のリスト) から結果を生成しません。
Python でhref
属性 title を含むハイパーリンクのテキスト (リンク) を取得するにはどうすればよいですか?lxml