首页 > 代码库 > requests-代理设置

requests-代理设置

 1 import requests
 2 
 3 proxies={
 4     http:http://192.168.1.1:88
 5     https:https://192.168.1.1:88
 6 #如果代理ip需要用户名和密码的话 ‘http‘:‘user:password@192.168.1.1:88‘
 7 }
 8 response = requests.get(url,proxies=proxies)
 9 print(response.status_code)
10 
11 #如果代理类型不是http或者https,而是socks代理
12 #需要先 pip3 install ‘requests[socks]
13 proxies={
14     http:socks5://192.168.1.1:88
15     https:socks5://192.168.1.1:88
16 #如果代理ip需要用户名和密码的话 ‘http‘:‘user:password@192.168.1.1:88‘
17 }

 

requests-代理设置