我想从以下源代码中提取“ 63”
<center><br><strong>Total 63 Customer Accounts found </strong><br>
运行代码后,它应该打印63
答案 0 :(得分:1)
尝试一下:
from bs4 import BeautifulSoup
soup_html ='<center><br><strong>Total 63 Customer Accounts found in DSLAM: 10.131.0.133</strong><br>'
soup = BeautifulSoup(soup_html , "html.parser")
str_res = soup.findAll(text=True)
result = [int(i) for i in str_res [0].split() if i.isdigit()]
print(result)
将返回63。