I try to parse src from image tag in python with lxml, but when I try to output imageurl I get following:
[<Element img at 0x921f68c>]
Here is my code:
xhtml = lxml.html.document_fromstring(html)
imageUrl = xhtml.xpath('//img[@alt="something"]')
Just append /@src
to your xpath expression:
imageUrl = xhtml.xpath('//img[@alt="something"]/@src')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With