English 中文(简体)
Requests - Proxy
  • 时间:2024-11-03

Requests - Proxy


Previous Page Next Page  

So far, we have seen cpents directly connecting and talking to the server. Using proxy, the interaction happens as follows −

    The cpent sends a request to the proxy.

    The proxy sends the request to the server.

    The server sends back the response to the proxy.

    The proxy will send a response back to the cpent.

Using Http-proxy is additional security assigned to manage the data exchange between cpent and server. The requests pbraries also have provision to handle proxy, by using the proxies param as shown below −

Example


import requests
proxies = {
 http :  http://localhost:8080 
}
res = requests.get( http://httpbin.org/ , proxies=proxies)
print(res.status_code) 

The request will route to http://localhost:8080 URL.

Output


200
Advertisements