标签:ada style arc dad 正则表达 tps int 网页 findall
‘‘‘
首先分析ip地址的特征:255.255.255.255,前三位的数字处理基本一致
1位: 0-9 \d
2位:10-99 [1-9]\d
3位:100-199 1\d\d
3位:200-249 2[0-4]\d
3位:250-255 25[0-5]
‘‘‘
先匹配前三位数字: (\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]) 前三位加上 . ((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3} 最后一位:只是不加. (\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])
ss=re.compile(r‘((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d)‘) print(ss.search(‘asdada172.26.133.84‘).group())
2、匹配网址:
print(‘4统计网页的所有链接‘)
#print(re.findall(r‘https?://.*‘,data))
s=‘<script src="https://account.sogou.com/static/api/sogou.js?t=2017110901" type="text/javascript" async=""></script>‘
#print(s)
print(re.search(r‘"(https?://.*?)"‘,s).group())
标签:ada style arc dad 正则表达 tps int 网页 findall
原文地址:https://www.cnblogs.com/xiaoxiao075/p/10351122.html