小编Sal*_*sha的帖子

使用Python中的beautifulsoup从网站中提取数字

我正在尝试使用urllib来获取一个html页面,然后使用beautifulsoup来提取数据.我想从comments_42.html获取所有数字并打印出它们的总和,然后显示数据的数量.这是我的代码,我正在尝试使用正则表达式,但它对我不起作用.

import urllib
from bs4 import BeautifulSoup
url = 'http://python-data.dr-chuck.net/comments_42.html'
html = urllib.urlopen(url).read()
soup = BeautifulSoup(html,"html.parser")
tags = soup('span')
for tag in tags:
    print tag
Run Code Online (Sandbox Code Playgroud)

python regex beautifulsoup

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

beautifulsoup ×1

python ×1

regex ×1