Install
Python 3.9 or newer.
pip install requestsRotating residential
Both keys point at the same http:// URL, including the https key: that key says which target URLs use the proxy, not how to talk to it. Calling requests.get without a session opens a new connection each time, so each line should print a different address.
import requests
PROXY = "http://USER:[email protected]:8000"
proxies = {"http": PROXY, "https": PROXY}
for _ in range(3):
r = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=(10, 30))
print(r.json()["origin"])A static datacenter or ISP IP
On a static datacenter IP you want connection reuse, because a new IP per request is not the point, so use a Session. For an ISP order, swap in the host and port your dashboard shows for it.
import requests
PROXY = "http://USER:PASS@IP:PORT"
with requests.Session() as s:
s.proxies.update({"http": PROXY, "https": PROXY})
for url in ["https://httpbin.org/ip", "https://httpbin.org/headers"]:
r = s.get(url, timeout=(10, 30))
print(r.status_code, r.text[:80])Keeping one identity
A requests.Session pools connections, and an HTTPS request through a proxy rides a tunnel that exits from one address. Reuse the tunnel and you reuse the IP, even on the rotating gateway. That is handy when you want a few requests to one site from the same address, and confusing when you expected rotation. For a residential IP that holds across new connections too, use a sticky session; the session setting for your account is in the dashboard.