【发布时间】:2011-06-29 09:26:38
【问题描述】:
我想通过python提取html中的段落。我使用了 lxml 模块,但它并没有完全符合我的要求。
print html.parse(url).xpath('//p')[1].text_content()
<span id="midArticle_1"></span><p>Here is the First Paragraph.</p><span id="midArticle_2"></span><p>Here is the second Paragraph.</p><span id="midArticle_3"></span><p>Paragraph Three."</p>
我应该补充一点,在不同的页面中,我有不同数量的段落,所以想列出一个列表,然后将段落放入其中。
【问题讨论】:
标签: python html-parsing lxml paragraphs