Skip to content
Alienproxies.com

Language

LoginRegister
Alienproxies.com
All posts
residentialpythonscrapingtutorial

Getting Started with Residential Proxies

Alienproxies.com Team · · 3 min read

Residential proxies route your traffic through real IP addresses assigned by ISPs to home users. For web scraping this matters a lot: targets like Google, Amazon, Ticketmaster, and social platforms block known datacenter IP ranges aggressively. A residential IP looks like a real user, so your requests get through.

This guide walks you through making your first request with Alienproxies.com residential proxies, then levels up to country targeting, sticky sessions, and async scraping at scale.

Prerequisites

  • An Alienproxies.com account with balance added
  • Python 3.9+ with requests installed (pip install requests)
  • Your proxy credentials (username + password from the dashboard)

Your First Request

Alienproxies.com uses a single gateway endpoint. Your username encodes all the targeting options.

import requests

proxies = {
    "http":  "http://user:[email protected]:7777",
    "https": "http://user:[email protected]:7777",
}

r = requests.get("https://httpbin.org/ip", proxies=proxies)
print(r.json())  # {"origin": "185.220.x.x"}

Each request gets a fresh IP from the residential pool. That's rotating mode — the default.

Country Targeting

Add -country-XX to your username to pin requests to a specific country. Use the two-letter ISO code.

# United States only
proxies = {
    "http":  "http://user-country-us:[email protected]:7777",
    "https": "http://user-country-us:[email protected]:7777",
}

You can go deeper — state, city, or carrier ASN:

# Los Angeles, California
username = "user-country-us-state-ca-city-losangeles"

# Specific carrier ASN (useful for mobile-network targeting)
username = "user-country-us-asn-7922"  # Comcast

Sticky Sessions

Some flows need the same IP across multiple requests — logging in, filling a multi-step form, or maintaining a shopping cart. Use sticky sessions with a TTL between 1 and 60 minutes.

import uuid

session_id = uuid.uuid4().hex[:8]  # any unique string
username = f"user-country-us-session-{session_id}-sesstime-10"

proxies = {
    "http":  f"http://{username}:[email protected]:7777",
    "https": f"http://{username}:[email protected]:7777",
}

# All requests with this username stay on the same IP for 10 minutes
for url in ["https://example.com/login", "https://example.com/account"]:
    r = requests.get(url, proxies=proxies)
    print(r.status_code)

Error Handling and Retries

Residential proxies occasionally time out or hit a blocked IP. Build a simple retry loop:

import requests
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry

def make_session(username: str, password: str) -> requests.Session:
    s = requests.Session()
    s.proxies = {
        "http":  f"http://{username}:{password}@gate.alienproxies.com:7777",
        "https": f"http://{username}:{password}@gate.alienproxies.com:7777",
    }
    retry = Retry(total=3, backoff_factor=0.5, status_forcelist=[500, 502, 503, 504])
    s.mount("https://", HTTPAdapter(max_retries=retry))
    s.mount("http://",  HTTPAdapter(max_retries=retry))
    return s

session = make_session("user-country-us", "YOUR_PASS")
r = session.get("https://target.com/product/12345", timeout=30)

Async Scraping at Scale

For high-volume work, use httpx with async:

import asyncio
import httpx

PROXY = "http://user-country-us:[email protected]:7777"

async def fetch(url: str, client: httpx.AsyncClient) -> str:
    r = await client.get(url, timeout=30)
    return r.text

async def main(urls: list[str]) -> list[str]:
    async with httpx.AsyncClient(proxy=PROXY) as client:
        return await asyncio.gather(*[fetch(u, client) for u in urls])

urls = [f"https://example.com/page/{i}" for i in range(100)]
results = asyncio.run(main(urls))
print(f"Fetched {len(results)} pages")

Checking Your Usage

Monitor GB consumed from the dashboard or via the API:

curl -H "Authorization: Bearer YOUR_API_KEY" \
  https://alienproxies.com/api/v1/usage

Next Steps