【发布时间】:2014-10-22 03:38:28
【问题描述】:
所以我需要在像这样的行之后获取数字
<div class="gridbarvalue color_blue">79</div>
和
<div class="gridbarvalue color_red">79</div>
有没有办法可以在findAll('div', text=re.recompile('<>)) 中找到带有gridbarvalue color_<red or blue> 的标签?
我正在使用 Beautifulsoup。
也很抱歉,如果我没有把我的问题说清楚,我对此非常缺乏经验。
【问题讨论】:
-
你的意思是要提取号码
79? -
是的,就像我说的那样有多行,我想抓住数字。
-
你想让它得到号码
79对吗? -
您应该能够使用 BeautifulSoup 来做到这一点,而无需正则表达式。查看已经发布的数千个问题,了解使用正则表达式解析 HTML 不好的原因。
标签: python regex beautifulsoup findall