1. 程式人生 > >python requests 測試代理ip是否生效

python requests 測試代理ip是否生效

wow 代理設置 req head app like quest spa keep

import requests
‘‘‘代理IP地址(高匿)‘‘‘
proxy = {
    http: http://117.85.105.170:808,
    https: https://117.85.105.170:808
}
‘‘‘head 信息‘‘‘
head = {User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36, 
             Connection: keep-alive
} ‘‘‘http://icanhazip.com會返回當前的IP地址‘‘‘ p = requests.get(http://icanhazip.com, headers=head, proxies=proxy) print(p.text)

如果代理設置成功,最後顯示的IP應該是代理的IP地址。

python requests 測試代理ip是否生效