logo_blue.png
Productsicon_bottom.png
Pricingicon_bottom.png$1.11/GB
Casesicon_bottom.png
Locationsicon_bottom.png
Resourcesicon_bottom.png

How to Use Proxies with Python on Windows (Requests, Scrapy, Selenium Explained)

Go2proxy
2026-01-30

Python is the dominant language for web scraping, automation, and data collection on Windows. However, Python proxy configuration is far more fragmented than most developers expect.

A setup that works perfectly with:

  • requests may completely fail with:
  • Scrapy
  • Selenium
  • Playwright
  • Headless Chrome

On Windows in particular, confusion increases because:

  • System proxy settings are inconsistent
  • Environment variables are not universally respected
  • Browser-based automation ignores Python-level proxy logic

This article provides a production-grade, tool-by-tool guide to using proxies with Python on Windows—without relying on trial and error.

Why Python Proxy Handling Is Inconsistent

Unlike browsers, Python has no unified proxy layer.

Each library decides:

  • Whether to read environment variables
  • How authentication is handled
  • Whether HTTPS tunneling is supported
  • How DNS resolution is performed

As a result:

“Proxy configured” does not mean “proxy actually used.”

Proxy Types You Should Use with Python

Before touching code, proxy quality matters.

Proxy TypeSuitability
Free proxiesUnstable, unsafe
Datacenter proxiesFast, easily blocked
Residential proxiesBest for scraping
ISP proxiesHigh trust, stable
Rotating proxiesMust be controlled
Sticky/session proxiesAutomation-safe

For Windows-based Python scraping and automation, session-based residential proxies (such as those provided by Go2Proxy) offer the best balance of trust and control.

Using Proxies with Python Requests (Most Common Case)

Basic Example

import requests

proxies = {
    "http": "http://username:password@proxy_ip:port",
    "https": "http://username:password@proxy_ip:port"
}

response = requests.get("https://example.com", proxies=proxies, timeout=15)
print(response.status_code)

Key Points

  • requests does not inherit Windows proxy settings
  • Explicit configuration is required
  • HTTPS proxies must support tunneling

Using Environment Variables (Optional)

setx HTTP_PROXY http://username:password@proxy_ip:port
setx HTTPS_PROXY http://username:password@proxy_ip:port

Requests will pick this up, but:

  • This does not apply to Selenium
  • It can cause hidden conflicts in multi-project environments

Explicit proxies are safer in production.

Common Requests Proxy Problems on Windows

1. Special Characters in Passwords

  • Must be URL-encoded
  • Otherwise authentication fails silently

2. SSL Errors

  • Caused by intercepting proxies
  • Use clean HTTPS proxies only

3. DNS Leaks

  • Requests resolves DNS locally
  • Target hostname may still be visible
  • High-quality residential proxies mitigate most of these issues.

Using Proxies with Scrapy on Windows

Scrapy does not behave like requests.

Enable Proxy Middleware

DOWNLOADER_MIDDLEWARES = {
    'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 750,
}

Assign Proxy Per Request

def start_requests(self):
    yield scrapy.Request(
        url="https://example.com",
        meta={
            "proxy": "http://username:password@proxy_ip:port"
        }
    )

Rotating Proxies in Scrapy

Bad practice:

  • Rotate IP per request
  • Causes CAPTCHAs and bans

Better approach:

  • Rotate per spider
  • Or per batch

Go2Proxy’s session-based endpoints allow stable sessions while still rotating between tasks.

Handling HTTPS in Scrapy

Scrapy requires:

  • Proxy supports HTTPS tunneling
  • Correct authentication formatting

If HTTPS fails:

  • Test proxy with curl
  • Verify credentials encoding
  • Check CA certificates

Selenium + Python on Windows: The Hardest Case

Selenium completely ignores Python proxy settings.

All proxy logic must be passed to the browser.

Chrome Proxy Configuration Example

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument(
    "--proxy-server=http://proxy_ip:port"
)

driver = webdriver.Chrome(options=chrome_options)

This works only for unauthenticated proxies.

Selenium with Authenticated Proxies (Real-World Setup)

Chrome does not support inline credentials.

Solutions:

  1. Custom Chrome extension
  2. Proxy authentication plugin
  3. Headless browser with built-in proxy support

Most production users prefer:

  • Playwright (better proxy support)
  • Or residential proxies with IP authentication

Selenium + Residential Proxies Best Practices

  • Use sticky sessions
  • Keep one IP per browser
  • Match proxy region to target site
  • Avoid rotating mid-session

Go2Proxy residential sessions are designed specifically for this workflow.

Python + Playwright (Recommended Alternative)

Playwright integrates proxy handling cleanly.

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(
        proxy={
            "server": "http://proxy_ip:port",
            "username": "username",
            "password": "password"
        }
    )

Advantages:

  • No extensions
  • Cleaner auth handling
  • Better Windows stability

Managing Proxies Across Multiple Python Projects

What Not to Do

  • Global environment variables
  • Hardcoding credentials
  • Sharing proxy pools across unrelated tasks

Recommended Approach

  • Configuration files
  • Environment injection
  • Secret management
  • Proxy-per-project isolation

Debugging Proxy Issues on Windows

Checklist:

  • Test proxy with curl
  • Confirm IP via IP-check service
  • Log outgoing IP
  • Monitor response headers
  • Capture browser network logs

If a proxy “works” but traffic still comes from your real IP, it is not configured correctly.

Performance Considerations

  • Residential proxies are slower than datacenter IPs
  • Avoid excessive concurrency
  • Reuse sessions
  • Measure per-IP latency

Stable proxies outperform fast-but-unstable ones.

Legal & Ethical Considerations

  • Respect robots.txt where applicable
  • Avoid scraping personal data
  • Follow local regulations
  • Use proxies responsibly

Conclusion

Using proxies with Python on Windows is not difficult—but it is inconsistent across libraries. Production-grade setups require understanding how each tool handles network traffic.

For serious scraping, automation, and data collection:

  • Explicit proxy configuration
  • Session-based residential IPs
  • Tool-appropriate integration

Providers like Go2Proxy are widely used in these workflows because they align with how modern Python tools actually operate.


Relate Tags: ,
telegram.png
contanceUs@2x.png