美文网首页Python3
python3-正则表达式(re)之获取网页全部url

python3-正则表达式(re)之获取网页全部url

作者: 车陂IT仔 | 来源:发表于2019-04-16 12:33 被阅读0次

有时候,我们需要获取网站的全部url,用作于其他测试

以sogoWeChat为例:

import re
import urllib.request

response = urllib.request.urlopen("https://weixin.sogou.com/")
html = response.read()
tag = re.findall(r'<a href="([a-zA-z]+://[^\s]*)"', str(html))
print(tag)
返回结果

推荐一个正则表达式在线验证网站:http://tool.oschina.net/regex/#

完美

相关文章

网友评论

    本文标题:python3-正则表达式(re)之获取网页全部url

    本文链接:https://www.haomeiwen.com/subject/lotbwqtx.html