我是解析新手..我有一个简单的 html,没有类属性列表,例如:
<h2><a href="..">Title 1</a></h2>
<ol>
<li>Line 1..</li>
<li>Line 2...</li>
...
</ol>
<h2><a href="..">Title 2</a></h2>
<ol>
<li>Line 2-1..</li>
<li>Line 2-2...</li>
...
</ol>
...
等等..
我运行这段代码:
import requests
from bs4 import BeautifulSoup as BS
r = requests.get('http://...')
html = BS(r.content, 'html.parser')
H2 = html.find_all('h2')
for h2 in H2:
title = h2.text
print(title)
获取标题..但是我如何<ol>在同一循环中获取分配给该标题的列表?
largeQ
HUX布斯
相关分类