Skip to content
ProxyHub
All guides

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. 1

    Install requests (and, for SOCKS5, requests[socks]).

  2. 2

    Build the proxy URL with username and password, using the http:// or socks5h:// scheme depending on the protocol.

  3. 3

    Pass it for http and https in the proxies dictionary.

  4. 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

Don't have a proxy yet?

Choose country, carrier and plan: the proxy activates right away.

See plans

Need a hand?

Dedicated 24/7 support on Telegram helps you set up any tool.

Message us on Telegram

More guides