【发布时间】:2013-01-21 18:11:58
【问题描述】:
我有一个像这样的简单 html 文件。事实上,我从 wiki 页面中提取了它,删除了一些 html 属性并转换为这个简单的 html 页面。
<html>
<body>
<h1>draw electronics schematics</h1>
<h2>first header</h2>
<p>
<!-- ..some text images -->
</p>
<h3>some header</h3>
<p>
<!-- ..some image -->
</p>
<p>
<!-- ..some text -->
</p>
<h2>second header</h2>
<p>
<!-- ..again some text and images -->
</p>
</body>
</html>
我用 python 和这样的美汤阅读了这个 html 文件。
from bs4 import BeautifulSoup
soup = BeautifulSoup(open("test.html"))
pages = []
我想做的是把这个 html 页面分成两部分。第一部分将在第一个标题和第二个标题之间。第二部分将在第二个标题
和
标签: python html beautifulsoup