Production-ready Python examples for using 4G mobile proxies with the most common scraping and automation libraries.
All examples use HexaProxy, a French 4G mobile proxy provider running real SIM cards on Orange, SFR, Bouygues Telecom, and Free Mobile networks. They will work with any HTTP/HTTPS proxy provider, but you'll get the best detection-bypass results with real mobile carrier IPs.
Modern anti-bot systems (Cloudflare, DataDome, PerimeterX, Akamai) classify IPs by ASN. Datacenter IPs are flagged in seconds. Residential IPs are better but often shared across dozens of users via P2P pools — meaning you inherit other people's reputation.
Mobile 4G IPs route through real cellular networks. Thanks to CGNAT (Carrier-Grade NAT), a single mobile IP is shared with thousands of legitimate users at the same time, making it nearly impossible for websites to block them without burning real customers.
For a deeper technical breakdown, read What Is a 4G Mobile Proxy?.
git clone https://github.com/Hexaproxytech/hexaproxy-python-examples.git
cd hexaproxy-python-examples
pip install -r requirements.txt
cp .env.example .env # then edit .env with your real credentials
python examples/01_requests_simple.py| File | Library | Use case |
|---|---|---|
01_requests_simple.py |
requests |
Basic GET/POST through a proxy |
02_aiohttp_async.py |
aiohttp |
Concurrent requests at scale |
03_playwright_browser.py |
playwright |
Headless browser scraping with proxy |
04_scrapy_settings.py |
scrapy |
Scrapy middleware configuration |
05_rotation_demo.py |
requests |
Trigger and observe IP rotation |
06_persistence_check.py |
requests |
Verify carrier-side IP stability over time |
These examples use placeholder credentials (demo_user:demo_pass@gateway.hexaproxy.tech:8000). To run them against a real proxy:
- Sign up at hexaproxy.tech
- Pick a SIM (€49.90/month, unlimited bandwidth, dedicated)
- Get your gateway endpoint, port, username, and password from your dashboard at hexaproxy.me
- Drop them into your
.envfile
If you're using these examples for ad account warm-up (Facebook, TikTok, Google Ads), pick Orange in your HexaProxy dashboard. Orange SIMs typically hold the same IP for several days without involuntary reassignment, which is what platforms expect from a "real human." Free Mobile rotates more often — better suited for high-volume scraping where IP diversity is a feature.
MIT — do whatever you want with the code. Attribution appreciated but not required.
Open issues and PRs welcome. If you've built a great example with another library (httpx, curl_cffi, pyppeteer, etc.), send it our way.
HexaProxy — French 4G mobile proxies for serious scrapers and media buyers. hexaproxy.tech · Blog · Dashboard