Lea*_*orm 1 html python tableofcontents
假设我有一些HTML代码,就像这样(从Markdown或Textile或其他东西生成):
<h1>A header</h1>
<p>Foo</p>
<h2>Another header</h2>
<p>More content</p>
<h2>Different header</h2>
<h1>Another toplevel header
<!-- and so on -->
Run Code Online (Sandbox Code Playgroud)
我怎么能用Python为它生成一个目录?
使用HTML解析器(如lxml或BeautifulSoup)查找所有标题元素.
| 归档时间: |
|
| 查看次数: |
722 次 |
| 最近记录: |