Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35834 > unrolled thread
| Started by | contro opinion <contropinion@gmail.com> |
|---|---|
| First post | 2012-12-31 14:32 +0800 |
| Last post | 2012-12-31 14:32 +0800 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
how to get the source of html in lxml? contro opinion <contropinion@gmail.com> - 2012-12-31 14:32 +0800
| From | contro opinion <contropinion@gmail.com> |
|---|---|
| Date | 2012-12-31 14:32 +0800 |
| Subject | how 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?
Back to top | Article view | comp.lang.python
csiph-web