Skip to main content
The requests library is the most popular way to make HTTP requests in Python. Integrating 2extract.com proxies is incredibly simple.

Basic Setup

To use our proxies, you just need to construct a proxies dictionary and pass it to your request. The dictionary should contain both http and https keys.
basic_setup.py
import requests

# 1. Get these from your proxy's "Connection Details" page
proxy_host = "proxy.2extract.net"
proxy_port = 5555
proxy_user = "PROXY_USERNAME"
proxy_pass = "PROXY_PASSWORD"

# 2. Construct the proxy URL
proxy_url = f"http://{proxy_user}:{proxy_pass}@{proxy_host}:{proxy_port}"

# 3. Set up the proxies dictionary
proxies = {
    "http": proxy_url,
    "https": proxy_url,
}

# 4. Make your request!
try:
    response = requests.get("https://api.ipify.org?format=json", proxies=proxies, timeout=10)
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    print("Success! Your proxy IP is:", response.json()['ip'])

except requests.exceptions.RequestException as e:
    print(f"Error making request: {e}")

Real-World Example: Scraping Steam Game Prices

Let’s solve a real problem: checking the price of a popular game, like Counter-Strike 2, in different regions. Many online stores have regional pricing, and using proxies is the only way to see what local users see. In this example, we’ll check the price in the USA and Turkey by dynamically changing the -country parameter in the username.
This example requires requests and BeautifulSoup4. Install them with pip install requests beautifulsoup4.
steam_scraper.py
import requests
from bs4 import BeautifulSoup

# --- Your Base Credentials ---
BASE_USERNAME = "PROXY_USERNAME"
PASSWORD = "PROXY_PASSWORD"
PROXY_HOST_PORT = "proxy.2extract.net:5555"

# --- Target Information ---
GAME_APP_ID = "730" # Counter-Strike 2 AppID
TARGET_URL = f"https://store.steampowered.com/app/{GAME_APP_ID}/"
REGIONS = ["us", "tr"] # USA and Turkey

# --- Main Scraper Logic ---
for region in REGIONS:
    print(f"--- Checking price in {region.upper()} ---")

    # Dynamically construct the username for each region
    proxy_username = f"{BASE_USERNAME}-country-{region}"

    proxies = {
        "http": f"http://{proxy_username}:{PASSWORD}@{PROXY_HOST_PORT}",
        "https": f"http://{proxy_username}:{PASSWORD}@{PROXY_HOST_PORT}",
    }

    # We must also pass the region code to Steam to get the correct store page
    # and cookies to bypass the age gate check.
    params = {'cc': region}
    cookies = {'birthtime': '568022401', 'wants_mature_content': '1'}
    headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'}

    try:
        response = requests.get(
            TARGET_URL,
            proxies=proxies,
            params=params,
            cookies=cookies,
            headers=headers,
            timeout=15
        )
        response.raise_for_status()

        # Parse the HTML to find the price
        soup = BeautifulSoup(response.text, 'html.parser')
        price_element = soup.find('div', class_='game_purchase_price')

        if price_element:
            print(f"Success! Price found: {price_element.get_text(strip=True)}")
        else:
            # Maybe it's on sale?
            discount_price_element = soup.find('div', class_='discount_final_price')
            if discount_price_element:
                print(f"Success! Discount price found: {discount_price_element.get_text(strip=True)}")
            else:
                print("Could not find the price element on the page.")

    except requests.exceptions.ProxyError as e:
        print(f"Proxy Error! Check your credentials or balance. Details: {e}")
    except requests.exceptions.HTTPError as e:
        print(f"HTTP Error! The target website blocked us. Status code: {e.response.status_code}")
    except requests.exceptions.RequestException as e:
        print(f"An unexpected error occurred: {e}")

    print("-" * (25 + len(region)))

Expected Output

Running this script will produce an output similar to this:
Terminal
--- Checking price in US ---
Success! Price found: $14.99
--------------------------
--- Checking price in TR ---
Success! Discount price found: ₺265,50
--------------------------
This example demonstrates the power of dynamically controlling your proxy’s location directly from your code, allowing you to build powerful, scalable data collection applications.
I