更新时间:2023-02-19 17:07:57
以下是使用 BeautifulSoup的示例解析HTML:
Here is an example of using BeautifulSoup to parse HTML:
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup("""<html><body>
<div id="a" class="c1">
We want to get this
</div>
<div id="b">
We don't want to get this
</div></body></html>""")
print soup('div', id='a').text
此输出
We want to get this