【发布时间】:2012-10-13 20:09:07
【问题描述】:
有人可以帮助我编写一些代码来从游戏中提取统计数据吗? 我可以将 html 放入 BeautifulSoup,但我不知道如何正确格式化正则表达式以获取整个页面的特定数据位。 这是我得到的:
from urllib import urlopen
from bs4 import BeautifulSoup
import re
content = urlopen('http://www.worldoftanks.com/community/accounts/1000395103-FrankenTank').read()
soup = BeautifulSoup(content)
print soup
如果你能告诉我如何提取一个统计数据,我就能弄清楚其余的。 其中一项统计数据是参与的战斗次数(10103),编码如下:
<tr>
<td class=""> Battles Participated: </td>
<td class="td-number-nowidth"> 10 103 </td>
</tr>
谢谢!
弗兰克
【问题讨论】:
-
正则表达式和这个有什么关系?您正在使用正确的 HTML 解析器,您不想在这里使用正则表达式..
标签: python regex web beautifulsoup scrape