All systems operational HTTP · HTTPS · SOCKS5 Global network
Documentation home Quickstart Engineering guides Code examples Global network Pricing Solutions overview Custom proxy pools Managed data scraping Contact Console
CODE EXAMPLE

Build a resilient proxy crawler with Python Requests.

Build a resilient proxy crawler with Python Requests. This example uses Rotating Proxies as the default gateway and can be adapted by replacing endpoint and routing credentials.

LanguagePython 3.11+FrameworkRequests + BeautifulSoupGatewayRotating ProxiesFilescrape.py
01
SETUP

Install the client and create a file.

Use a clean project environment and pin tested dependency versions for production. The example target is a public scraping sandbox.

Installpython -m pip install requests beautifulsoup4
02
CREDENTIALS

Load proxy secrets from the environment.

The proxy username is not the LundProxy website login. Copy the complete username and password generated for the selected proxy product.

PROXY_USER=user-pool-crawlerPROXY_PASS=your-secret
03
COMPLETE EXAMPLE

scrape.py

Copy the code into the named file, set credentials, and run it from the project environment.

import os
import requests
from bs4 import BeautifulSoup

proxy = (
    "http://"
    f"{os.environ['PROXY_USER']}:{os.environ['PROXY_PASS']}"
    "@proxy.lundproxy.com:36923"
)

with requests.Session() as session:
    session.proxies.update({"http": proxy, "https": proxy})
    response = session.get(
        "https://quotes.toscrape.com/",
        timeout=(10, 30),
    )
    response.raise_for_status()

soup = BeautifulSoup(response.text, "html.parser")
for quote in soup.select(".quote"):
    print({
        "text": quote.select_one(".text").get_text(strip=True),
        "author": quote.select_one(".author").get_text(strip=True),
    })
04
WHAT THE EXAMPLE DOES

Keep the important behavior visible.

01Credentials stay in environment variables.
02Connect and read timeouts are explicit.
03HTTP errors fail before parsing.
04One Session reuses connections.
05
PRODUCTION NOTES

Add workload-specific controls before scale.

A successful sandbox run proves integration, not production readiness.

Test representative targets, response sizes, routing policy, concurrency, retries, validation, and completion window. Collect only public data you are authorized to access.

06
EXAMPLE FAQ

Requests + BeautifulSoup questions.

Why use a Session?

It reuses connections and keeps proxy configuration in one client object.

Where should retries live?

Use a bounded adapter or job-level retry policy that distinguishes safe transient failures from target responses.

How do I use Premium Residential?

Replace the gateway and use the full country and SESSION username generated by the console.