如何编写 Python 正则表达式以获取网页中的所有锚点标签?

如何编写 Python 正则表达式以获取网页中的所有锚点标签?

下面的代码提取给定字符串中的所有标签。

更多Python相关文章,请阅读:Python 教程

示例

import re
rex = re.compile(r'[\<\>]')
l = "this is text1 <a href='irawati.com' target='_blank'>hi</a> this is text2"
print rex.findall(l)

输出

['<', '>', '<', '>']

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程