import re
# url通用匹配
url_regex = re.compile('<a[^>]+href=["\'](.*?)["\']', re.IGNORECASE)
# test
url_str = "<a type='akfdf' href='http://www.itmeng.top' xxxx>hahah</a>"
result = url_regex.findall(url_str)
print(result)
# ---------运行结果------------
>>> print(result)
['http://www.itmeng.top']
通用正则, 抓取a标签href属性
最新推荐文章于 2025-03-26 07:30:00 发布