Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我尝试使用lxml从python中的图像标签解析src,但是当我尝试输出imageurl时,我得到以下信息:
[<Element img at 0x921f68c>]
这是我的代码:
xhtml = lxml.html.document_fromstring(html) imageUrl = xhtml.xpath('//img[@alt="something"]')
只需附加/@src到您的 xpath 表达式:
/@src
imageUrl = xhtml.xpath('//img[@alt="something"]/@src')