March 2019
Beginner
490 pages
12h 40m
English
An interesting feature offered by the Requests module is the possibility to make requests through a proxy or intermediate machine between our internal network and the external network. A proxy is defined in the following way:
>>> proxy = {"protocol":"ip:port", ...}
To make a Request through a proxy, the proxies attribute of the get method is used:
>>> response = requests.get(url,headers=headers,proxies=proxy)
The proxy parameter must be passed in the form of a dictionary; that is, you have to create a dictionary type where we specify the protocol with the IP address and the port where the proxy is listening:
>>> import requests >>> http_proxy = "http://<ip_address>:<port>" >>> proxy_dictionary = { "http" : http_proxy} >>> requests.get("http://example.org", ...Read now
Unlock full access