问题描述
我有一个像这样的简单html文件.实际上,我是从Wiki页面中提取它的,删除了一些html属性并转换为这个简单的html页面.
I have a simple html file like this. In fact I pulled it from a wiki page, removed some html attributes and converted to this simple html page.
<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文件.
I read this html file using python and beautiful soup like this.
from bs4 import BeautifulSoup
soup = BeautifulSoup(open("test.html"))
pages = []
我想做的就是将此html页面分为两部分.第一部分在第一标题和第二标题之间.第二部分将位于第二个标头