Href attribute for lxml.html
according to this answer :
>>> from lxml.html import fromstring
>>> s = """<input type="hidden" name="question" value="1234">"""
>>> doc = fromstring(s)
>>> doc.value
'1234'
>>> doc.name
'question'
I tried to get both link and text from this code:
from lxml.html import fromstring
s = '<a href="http://a.com" rel="bookmark">bla bla bla</a>'
doc = fromstring(s)
print (doc.href)
print (doc.text_content())
He gives AttributeError:'HtmlElement' object has no attribute 'href'
Im new in lxml. What was the real problem?
How can I use both link (a.com) and text (bla bla bla) as lines from this code?
+3
source to share