Prompt

How do I integrate residential proxies into a scraping workflow?

Latest observation

Aug 19, 2026 · Gemini APIWeb search: on

Integrating residential proxies into a web scraping workflow requires understanding proxy credentials, choosing the right rotation mode, and configuring your scraping tools effectively.


1. Understand Connection Formats and Modes

Residential proxy providers generally give you a single Backconnect Endpoint (URL and Port) along with authentication credentials.

Standard Proxy URL Format:

http://username:password@gate.proxyprovider.com:8080

Key Operating Modes:

  • Rotating Proxies (Per-Request Rotation): Every request automatically gets routed through a new residential IP. Ideal for large-scale, stateless scraping (e.g., e-commerce product catalogs).
  • Sticky Sessions: Keeps the same IP address for a specific duration (e.g., 5–30 minutes). Providers usually let you pass session parameters in the username (e.g., username-session-abc123). Ideal for multi-step workflows like logging into a account or completing a checkout flow.

2. Integration Examples

A. Python requests (Standard HTTP Scraping)

Pass the proxy URL via the proxies parameter in Python.

import requests

# For per-request rotation:
proxy_url = "http://username:password@gate.proxyprovider.com:8080"

# For sticky sessions (provider-dependent convention):
# proxy_url = "http://username-session-session123:password@gate.proxyprovider.com:8080"

proxies = {
    "http": proxy_url,
    "https": proxy_url,
}

try:
    response = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=10)
    print(response.json())  # Displays the residential IP being used
except requests.exceptions.RequestException as e:
    print(f"Proxy request failed: {e}")

B. Playwright (Headless Browser Scraping)

When rendering JavaScript-heavy pages, pass the proxy configuration during context or browser creation.

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(
        headless=True,
        proxy={
            "server": "http://gate.proxyprovider.com:8080",
            "username": "your_username",
            "password": "your_password"
        }
    )
    context = browser.new_context()
    page = context.new_page()

    page.goto("https://httpbin.org/ip")
    print(page.inner_text("body"))
    
    browser.close()

C. Scrapy (Asynchronous Framework)

In Scrapy, you can inject proxies via custom Downloader Middleware or pass them in request metadata (meta).

Using Request Metadata:

import scrapy

class ExampleSpider(scrapy.Spider):
    name = "example"
    
    def start_requests(self):
        url = "https://httpbin.org/ip"
        proxy_auth = "http://username:password@gate.proxyprovider.com:8080"
        
        yield scrapy.Request(
            url=url,
            callback=self.parse,
            meta={'proxy': proxy_auth}
        )

    def parse(self, response):
        self.logger.info(f"Page contents: {response.text}")

3. Workflow Best Practices

1. Implement Retry Logic and Error Handling

Residential proxy IPs are real devices, meaning they can disconnect or experience latency unexpectedly. Your pipeline should automatically retry requests on failures:

  • Retry on HTTP status codes: 403, 429 (Rate Limited), 502, 503, and 504.
  • Handle connection timeouts gracefully by setting strict per-request timeouts (e.g., 10–15 seconds).

2. Cost & Bandwidth Optimization

Most residential proxies are billed per Gigabyte of data transferred.

  • Block Heavy Assets: In Playwright/Puppeteer/Selenium, block image, font, stylesheet, and media downloads to cut bandwidth usage by up to 80%.
  • Filter Off-Domain Analytics: Block tracking scripts (e.g., Google Analytics, Facebook Pixel) that unnecessarily consume bandwidth.

Playwright Asset Blocking Example:

page.route("**/*.{png,jpg,jpeg,gif,webp,css,woff,woff2}", lambda route: route.abort())

3. Align Headers and Geolocation

  • Headers: Match your HTTP headers (e.g., Accept-Language, User-Agent) to the geographical location of the proxy IP. Sending a Japanese Accept-Language header through a US residential IP is a red flag for anti-bot systems.
  • TLS / Browser Fingerprinting: If using simple HTTP libraries (requests, axios), modern anti-bot systems (like Cloudflare or Akamai) can flag requests via TLS fingerprinting. Combine residential proxies with fingerprint-mimicking tools (like curl_cffi in Python) or headless browsers for strict targets.

4. Monitor Proxy Performance

Log key metrics in your scraping pipeline:

  • Success Rate: Monitor percentage of 200 OK responses vs. 403/429 blocks.
  • Response Time: Measure proxy latency to identify slow IP subnets or regions.
  • Data Usage: Track per-job megabytes spent to keep costs predictable.

Observation history

See 3 earlier observations

Create a free Obsurfable account to unlock historical responses, model comparisons, and deeper brand intelligence.

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (4 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, and Meta AI.