python 代理IP



import requests

#----------------------------------------------------------------------
def test(ip):
    """"""
    headers={
        'Accept-Language':'zh-CN,zh;q=0.9',
     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36',
     'X-Forwarded-For':ip,
     'referer':'https://www.baidu.com/',
     'Content-Type': 'multipart/form-data; session_language=cn_CN'
    }
    sss=requests.get(url="http://yantuz.cn/",headers=headers)    
    print sss.status_code
ip_list = ['1.2.3.4','123.123.123.123']
for i in ip_list:
    try:
        test(i)
    except Exception,e:
        pass