<reponame>maxiao5521/python<filename>mxn02.py
import urllib.request
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36'}
proxy_handle = ({'http':'http://172.16.31.10:33913'},{'http':'http://172.16.17.32:8060'},{'http':'http://172.16.58.3:53281'})
for proxy_handle in proxy_handle:
    try:
        opener = urllib.request.build_opener(proxy_handle)
        reponse = opener.open('http://www.baidu.com')
        if response.status==200:
            print('请求成功')
        else:
            print('url错误') 
    except:
        print('代理失效')
import urllib.request
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36'}
proxy_handle = ({'http':'http://172.16.31.10:33913'},{'http':'http://172.16.17.32:8060'},{'http':'http://172.16.58.3:53281'})
for proxy_handle in proxy_handle:
    try:
        opener = urllib.request.build_opener(proxy_handle)
        reponse = opener.open('http://www.baidu.com')
        if response.status==200:
            print('请求成功')
        else:
            print('url错误') 
    except:
        print('代理失效')