python http 使用代理

孤街醉人 提交于 2019-12-12 11:35:13

 

def inspect_ip(ipprot):
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
    }
    url = 'http://pv.sohu.com/cityjson'
    proxies = {
        "http":str(ipprot)
    }
    request = requests.get(url, headers=headers,proxies=proxies,timeout=2)
    if request.status_code == 200:
        print('可用代理' + ipprot)
        print(request.text)
    else:
        print('不可用代理' + ipprot)

  

if __name__ == '__main__':
    inspect_ip("116.196.115.209:8080")

 

免费代理地址 

https://www.zdaye.com/dayProxy.html

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!