来源如下:
<span class="new"> <a class="blog" href="http://whatever1.com" rel="nofollow">whatever1</a> do something at <a class="others" href="http://example1.com" rel="nofollow">example1</a></span>
<span class="new"> <a class="blog" href="http://whatever2.com" rel="nofollow">whatever2</a> do other things at <a class="others" href="http://example2.com" rel="nofollow">example2</a></span>
<span class="new"> <a class="blog" href="http://whatever3.com" rel="nofollow">whatever3</a> do something at <a class="others" href="http://example3.com" rel="nofollow">example3</a></span>
我想找到所有包含do something at
的<span class="new">
,下面是我的代码,我只是不知道它为什么不起作用:
什么也没找到。如果我删除text = re.compile('.*do something.*')
以上所有的标记都可以找到,我知道我的regex模式应该有问题,那么正确的形式是什么?在
迭代html文件内容并打印匹配的行。这里我用列表l替换了文件内容:
您可以尝试混合方法:
这就是我通常查找文本的方式。
相关问题 更多 >
编程相关推荐