我可以通过beautifulsoup在以下HTML标签中获取数字吗?
<tr align="center" height="15" id="tr_1599656" bgcolor="#ffffff" index="0"></tr>
<tr align="center" height="15" id="tr_1599657" bgcolor="#ffffff" index="1"></tr>
<tr align="center" height="15" id="tr_1599644" bgcolor="#ffffff" index="2"></tr>
我尝试过的Python代码
from bs4 import BeautifulSoup
import re
html_code = """"
<tr align="center" height="15" id="tr_1599656" bgcolor="#ffffff" index="0"></tr>
<tr align="center" height="15" id="tr_1599657" bgcolor="#ffffff" index="1"></tr>
<tr align="center" height="15" id="tr_1599644" bgcolor="#ffffff" index="2"></tr>
"""
soup = BeautifulSoup(html_code,'html.parser')
rows = soup.findAll("tr", {"id" : re.compile('tr_*\d')})
print rows
预期产量
1599656
1599657
1599644
HUH函数
噜噜哒
相关分类