当前位置: 移动技术网 > IT编程>脚本编程>Python > Crawler利用python尝试获取cn-proxy代理的IP地址(Jason niu)

Crawler利用python尝试获取cn-proxy代理的IP地址(Jason niu)

2018年03月18日  | 移动技术网IT编程  | 我要评论

唐家三少的所有小说,无疼蓝,莎拉苟萨的末日

Crawler利用python尝试获取cn-proxy代理的IP地址(Jason niu)

import urllib.request
import re 
import os

print(os.getcwd())

def open_url(url):
    req=urllib.request.Request(url) 
    req.add_header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.90 Safari/537.36 2345Explorer/9.2.1.17116")
    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__=="__mian__":
    url="https://cn-proxy.com"  
    get_img(open_url(url))   
    
url="https://cn-proxy.com"     
get_img(open_url(url)) 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网