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


Groups > comp.lang.python > #35834 > unrolled thread

how to get the source of html in lxml?

Started bycontro opinion <contropinion@gmail.com>
First post2012-12-31 14:32 +0800
Last post2012-12-31 14:32 +0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

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

#35834 — how to get the source of html in lxml?

Fromcontro opinion <contropinion@gmail.com>
Date2012-12-31 14:32 +0800
Subjecthow to get the source of html in lxml?
Message-ID<mailman.1485.1356935528.29569.python-list@python.org>

[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?

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web