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?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <contropinion@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.094
X-Spam-Evidence '*H*': 0.82; '*S*': 0.01; 'url:blog': 0.09; 'skip:f 30': 0.15; 'to:name:python-list': 0.15; 'urllib': 0.16; 'code,': 0.18; 'import': 0.21; 'message-id:@mail.gmail.com': 0.27; 'run': 0.28; 'source': 0.29; 'code': 0.31; 'skip:b 40': 0.32; 'print': 0.32; 'received:74.125.82': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'text': 0.34; 'skip:b 50': 0.35; 'subject:?': 0.35; 'received:74.125': 0.36; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'subject:get': 0.81; 'subject:source': 0.84; 'url:cn': 0.97
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=7XjLeMrCCNl8VweyxdED4/o2Y3kY2Hb2OvJS8KX8RDE=; b=a/naIltH3N9qb9PhA66C9i1vgrOsBgjjHZg3vQITaZGMJqE09v4bgYIVVf/4fiRIvK 1qqiAIJ27lyT3tP7Rz/TFKfgGIMxXNXEEVGHcskENaRqxDVY/uTcPYttz7xum4aFclcO wcqMaE3K1cjLwz/RcgkEeXdENr9XkROkLM2VotnghI/F7Kg/BMrgU9LZ25bVdrZ5IArH TikY2jb5sS0zWH3G07q+WXRD+aa3FWN7iNzNRg/P6LRmt1smZ5YLbG5j16kvPwYJCGEt J32uvjNxPsEBe9ifu9UIsZtMYYPkLbzYBPxOjhBiZaBxfUljVN9ZklLEudrMtDpShUXK iP2g==
MIME-Version 1.0
Date Mon, 31 Dec 2012 14:32:01 +0800
Subject how to get the source of html in lxml?
From contro opinion <contropinion@gmail.com>
To python-list <python-list@python.org>
Content-Type multipart/alternative; boundary=f46d0445182dc1db5b04d2202bfe
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1485.1356935528.29569.python-list@python.org> (permalink)
Lines 49
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1356935528 news.xs4all.nl 6857 [2001:888:2000:d::a6]:58068
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:35834

Show key headers only | 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