python http 使用代理

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

猜你喜欢

转载自www.cnblogs.com/su-king/p/12028086.html
今日推荐