PI ProxiesPI ProxiesDashboard
7 min read

How to Use SOCKS5 Proxies for Web Scraping

Set up SOCKS5 proxies for reliable, large-scale web scraping - authentication, rotation, sticky sessions, and code examples.


SOCKS5 proxies are a favorite among scraping engineers because they forward virtually any TCP traffic, not just web requests. This guide walks through setting up SOCKS5 proxies for reliable, large-scale web scraping - from authentication to rotation and code examples.

Why SOCKS5 for scraping?

Unlike HTTP proxies, which understand and parse web requests, SOCKS5 operates at a lower level and simply relays packets. That makes it protocol-agnostic and well suited to headless browsers, custom clients, and tools that go beyond plain HTTP. Paired with a residential pool, SOCKS5 gives you both flexibility and high trust scores.

Step 1: Get your credentials

After topping up your wallet, generate a proxy username and password from your dashboard. You'll receive a host, a port, and credentials. PI Proxies also supports IP whitelisting if you prefer not to send credentials in your client.

Step 2: Connect from your code

Most HTTP clients accept a SOCKS5 URL directly. In Python with requests:

import requests

proxies = {
    "http": "socks5://USER:PASS@HOST:PORT",
    "https": "socks5://USER:PASS@HOST:PORT",
}

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

For this to work, install the SOCKS extra with pip install requests[socks].

Step 3: Rotate IPs

By default, PI Proxies assigns a fresh residential IP on every request, which spreads your traffic across the pool and minimizes blocks. When you need to keep the same IP through a multi-step flow - a login, a paginated listing, or a cart - request a sticky session for 1 to 60 minutes using username flags.

Step 4: Target a location

Pin a country, state, city, or ASN with the same username flags. This is essential for price monitoring and localized SERP collection, where results differ by region.

Best practices

Wrapping up

SOCKS5 proxies give scraping pipelines the flexibility to handle anything from a simple GET to a full headless-browser session. Combine them with automatic rotation and geo-targeting and you can collect public data at scale while keeping your success rate high.