# coding=utf-8
import re
content = '''
<a href = "http://news.baidu.com" name = "tj_trnews" class = "mnav">新闻</a>
<a href = "http://www.hao123.com" name = "tj_trhao123" class = "mnav"> hao123 </a>
<a href = "http://map.baidu.com" name = "tj_trmap" class = "mnav">地图</a>
<a href = "http://v.baidu.com" name = "tj_trvideo" class = "mnav">视频</a>
'''
res = r"(?<=href=\").+?(?=\")|(?<=href=\').+?(?=\')"
urls = re.findall(res,content,re.I|re.S|re.M)
for url in urls:
print(url)
这一段代码本来是爬取超链接的URL,是北航杨老师的著作上的代码案例,
但是对于python3.7版本,运行好像就没反应,求解应该怎么修改。
正确结果应该会输出content中的四个URL连接地址。