我正在使用此代码查找页面中所有有趣的链接:
soup.findAll('a', href=re.compile('^notizia.php\?idn=\d+'))
它的工作做得很好。不幸的是,在a标记中有很多嵌套标记,如font,b和不同的东西。。。我只想得到文本内容,没有任何其他html标记。
链接示例:
<A HREF="notizia.php?idn=1134" OnMouseOver="verde();" OnMouseOut="blu();"><FONT CLASS="v12"><B>03-11-2009: <font color=green>CCS Ingegneria Elettronica-Sportello studenti ed orientamento</B></FONT></A>
当然很难看(而且标记也不总是一样!)我想得到:
03-11-2009: CCS Ingegneria Elettronica-Sportello studenti ed orientamento
在文档中,它说要在findAll方法中使用text=True
,但它将忽略我的regex。为什么?我该怎么解决?
目前没有回答
相关问题 更多 >
编程相关推荐