Budget Proxies logo
Python

Send your first Python request through a proxy

Python's requests library takes the proxy, login included, as a single address, which makes it a gentle first step.

Three steps to see it working

First, buy a plan. Datacenter costs less than the other types, so it suits a first test. Second, copy four details from your dashboard: the host (the proxy server's name or IP address), the port (a number written after the host, with a colon in between), your username and your password. Third, paste them into the sample below. Your login replaces USERNAME and PASSWORD, while gateway.proxy:8080 stands in for your host and port, so swap yours in wherever those appear. Then run it. The sample asks a website which IP address it can see, and if the answer isn't your own IP, the proxy is doing its job. It relies on a library (ready-made code that sends web requests for you); the libraries listed further down need the same details, though each has its own place to put them. Keep in mind that a proxy only changes the address a site sees, so your script must still follow that site's terms and the law where you live.

Python
import requests

proxy = "http://USERNAME:[email protected]:8080"

r = requests.get(
    "https://api.ipify.org?format=json",
    proxies={"http": proxy, "https": proxy},
    timeout=30,
)
print(r.json())   # the proxy's exit IP

These libraries need the same four details

requests httpx Scrapy Selenium Playwright

Writing in a different language?