Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #35834

how to get the source of html in lxml?

Date 2012-12-31 14:32 +0800
Subject how to get the source of html in lxml?
From contro opinion <contropinion@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1485.1356935528.29569.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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?

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

how to get the source of html in lxml? contro opinion <contropinion@gmail.com> - 2012-12-31 14:32 +0800

csiph-web