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.
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.
python -m pip install requests beautifulsoup4Load 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-secretscrape.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),
})
Keep the important behavior visible.
Add workload-specific controls before scale.
Test representative targets, response sizes, routing policy, concurrency, retries, validation, and completion window. Collect only public data you are authorized to access.
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.