import urllib.request
import re


def open_url(url):
    req  = urllib.request.Request(url)
    req.add_header("User-Agent",'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36')
    response = urllib.request.urlopen(req)
    page = urllib.request.urlopen(req)
    html = page.read().decode('utf-8')
    return html

def get_img(html):
    p =  r'(?:(?:[0,1]?\d?\d|2[0-4]\d|25[0-5])\.){3}(?:[0,1]?\d?\d|2[0-4]\d|25[0-5])'
    iplist = re.findall(p,html) 
    for each in iplist:
        print(each) 

if __name__ == "__main__":
    url = "http://www.xsdaili.com/dayProxy/ip/1021.html"
    get_img(open_url(url))
    

python正则表达式获取代理IP网站上的IP地址

相关文章:

  • 2021-07-17
  • 2022-12-23
  • 2022-12-23
  • 2021-06-03
  • 2021-09-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-22
  • 2021-10-20
  • 2021-07-12
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
相关资源
相似解决方案