Scripts and development
Use the proxy in Python (requests)
With requests the proxy is passed through the proxies parameter. SOCKS5 needs the extra support: pip install "requests[socks]".
Step by step
- 1
Install requests (and, for SOCKS5, requests[socks]).
- 2
Build the proxy URL with username and password, using the http:// or socks5h:// scheme depending on the protocol.
- 3
Pass it for http and https in the proxies dictionary.
- 4
For a new IP, call the rotation link and wait about 20 seconds.
Python
import time
import requests
PROXY = "http://USER:PASSWORD@HOST:PORT" # SOCKS5: "socks5h://USER:PASSWORD@HOST:PORT"
proxies = {"http": PROXY, "https": PROXY}
print(requests.get("https://api.ipify.org", proxies=proxies, timeout=30).text)
# New IP
requests.get("ROTATION_LINK", timeout=60)
time.sleep(20)
print(requests.get("https://api.ipify.org", proxies=proxies, timeout=30).text)Replace USER, PASSWORD, HOST and PORT with your proxy's data (client area › proxy › Connection).
Tips
- Use a requests.Session() to reuse the connection across requests.
- Always set a timeout: during rotation the proxy is disconnected for a few seconds.
