【发布时间】:2013-03-28 21:18:12
【问题描述】:
我有这个 html:
title="Keeper: Michal Buchalik" class="pos_text">Buchalik</a></span>
<span class="pos_text pos3_l_5">
我尝试匹配Buchalik。
我想出了这个代码:
for gk in soup.find_all(re.compile("pos_text pos3_l_\d{1,2}")):
print gk.previous_element.previous_element,
它不匹配任何东西,正则表达式一定有问题,因为当我输入某个数字代替\d{1,2} 时,它工作得很好。
【问题讨论】:
-
我在我的正则表达式中发现了一个明显的错误,这部分代码丢失了
class_=,尽管它仍然没有给我预期的输出。
标签: python regex python-2.7 beautifulsoup