how to get the source of html in lxml?

contro opinion contropinion at gmail.com
Mon Dec 31 07:32:01 CET 2012


import urllibimport lxml.html
down='http://blog.sina.com.cn/s/blog_71f3890901017hof.html'
file=urllib.urlopen(down).read()
root=lxml.html.document_fromstring(file)
body=root.xpath('//div[@class="articalContent  "]')[0]print body.text_content()

When i run the code, what i get is the text content ,how can i get the html
source code of it?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121231/d91064de/attachment.html>


More information about the Python-list mailing list