I have this HTML:
<a href="some content">Click here</a>
如何在Python 2.7中使用XPath提取some content
和click me
?
目前我有以下代码(从href结果中只提取“some content”):
import lxml.etree as LE
import requests
r = requests.get("http://localhost")
html = r.text
root = LH.fromstring(html)
print root.xpath('//a/@href')