Extract href values with xpath on Python 2.7
html, python, xpath
Solution
You can only select one or the other using XPath, but you could select all `<a>` elements and then pick off the `href` attribute and text content like this:
for elt in root.xpath('//a'):
print(elt.attrib['href'], elt.text_content())
Problem
I have this HTML: ``` <a href="some content">Click here</a> ``` How can I extract `some content` and `click me` with `xpath` on Python 2.7? So far i have the following ( extract only "some content" from href results): ``` import lxml.etree as LE import requests r = requests.get("http://localhost") html = r.text root = LH.fromstring(html) print root.xpath('//a/@href') ```