GProxy + Python requests — Complete 2026 Integration Guide
Use GProxy residential, datacenter or IPv6 proxies with the Python requests library in 4 lines of code. This guide covers HTTP/SOCKS5 authentication, session reuse, rotation, error handling, and common pitfalls — with copy-paste examples.
Prerequisites
- ✓Python 3.7 or newer
- ✓requests library installed (pip install requests)
- ✓For SOCKS5: requests[socks] (pip install requests[socks])
- ✓GProxy account with active credentials (residential, datacenter or IPv6)
Step-by-Step Setup
Install dependencies
Install the requests library. If you plan to use SOCKS5 proxies, install the socks extra.
pip install requests
pip install requests[socks] # for SOCKS5 support
Get your GProxy credentials
Log into your GProxy dashboard and copy your proxy host, port, username, and password from the relevant product page (Residential / Premium Datacenter / IPv6).
Use HTTP proxy with authentication
The simplest form. Pass a proxies dict to requests. GProxy uses Basic Auth in the URL.
import requests
proxies = {
'http': 'http://USERNAME:PASSWORD@dc.gproxy.net:8080',
'https': 'http://USERNAME:PASSWORD@dc.gproxy.net:8080',
}
r = requests.get('https://api.ipify.org?format=json', proxies=proxies, timeout=15)
print(r.json())
# {'ip': '<your-proxy-egress-ip>'}
Use SOCKS5 proxy
For SOCKS5, prefix the URL with socks5h:// (the h means DNS resolution happens on the proxy side — important for anonymity).
import requests
proxies = {
'http': 'socks5h://USERNAME:PASSWORD@proxy.gproxy.net:1080',
'https': 'socks5h://USERNAME:PASSWORD@proxy.gproxy.net:1080',
}
r = requests.get('https://api.ipify.org?format=json', proxies=proxies, timeout=15)
print(r.json())
Reuse a session for multiple requests
For multiple requests through the same proxy (and to keep keep-alive connections), use a Session. This is dramatically faster than creating a new request each time.
import requests
session = requests.Session()
session.proxies = {
'http': 'http://USERNAME:PASSWORD@dc.gproxy.net:8080',
'https': 'http://USERNAME:PASSWORD@dc.gproxy.net:8080',
}
for url in ['https://example.com/page1', 'https://example.com/page2']:
r = session.get(url, timeout=15)
print(r.status_code, len(r.content))
Rotate proxies per request
For rotating residential or IPv6 proxies, each new connection gets a fresh IP from the pool. Use a list and pick at random or round-robin.
import random
import requests
PROXIES = [
'http://USERNAME:PASSWORD@rp.gproxy.net:8001',
'http://USERNAME:PASSWORD@rp.gproxy.net:8002',
'http://USERNAME:PASSWORD@rp.gproxy.net:8003',
]
def fetch(url):
proxy_url = random.choice(PROXIES)
return requests.get(url, proxies={'http': proxy_url, 'https': proxy_url}, timeout=15)
for _ in range(5):
r = fetch('https://api.ipify.org?format=json')
print(r.json())
Handle errors and retries
Network errors and proxy timeouts happen. Wrap calls in try/except and retry with a different proxy. urllib3.Retry handles HTTP-level retries automatically.
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
retry_strategy = Retry(
total=3,
backoff_factor=1,
status_forcelist=[429, 500, 502, 503, 504],
allowed_methods=['GET', 'POST'],
)
adapter = HTTPAdapter(max_retries=retry_strategy)
session = requests.Session()
session.mount('http://', adapter)
session.mount('https://', adapter)
session.proxies = {'http': 'http://USERNAME:PASSWORD@dc.gproxy.net:8080',
'https': 'http://USERNAME:PASSWORD@dc.gproxy.net:8080'}
try:
r = session.get('https://example.com', timeout=15)
r.raise_for_status()
except requests.exceptions.ProxyError:
print('Proxy failed — rotate to next')
except requests.exceptions.Timeout:
print('Timeout — increase timeout or change proxy')
except requests.exceptions.RequestException as e:
print(f'Other error: {e}')
Code Examples
import requests
proxies = {'http': 'http://USER:PASS@dc.gproxy.net:8080',
'https': 'http://USER:PASS@dc.gproxy.net:8080'}
print(requests.get('https://api.ipify.org?format=json', proxies=proxies).json())
import httpx
import asyncio
async def fetch_all(urls):
async with httpx.AsyncClient(proxy='http://USER:PASS@dc.gproxy.net:8080') as client:
return await asyncio.gather(*[client.get(u) for u in urls])
results = asyncio.run(fetch_all(['https://example.com/p1', 'https://example.com/p2']))
for r in results:
print(r.status_code)
import requests
session = requests.Session()
session.proxies = {'http': 'http://USER:PASS@dc.gproxy.net:8080',
'https': 'http://USER:PASS@dc.gproxy.net:8080'}
session.headers.update({
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
'Accept-Language': 'en-US,en;q=0.9',
})
resp = session.get('https://example.com/login')
# Cookies persist across requests automatically
resp = session.post('https://example.com/login', data={'user': 'me', 'pass': 'x'})
Why pair Python requests with GProxy?
Python requests is the most-installed Python HTTP library — over 30 billion total downloads. Adding GProxy proxies takes 2 lines of code and unlocks every scraping, monitoring, and automation workflow that requires IP rotation, geo-targeting, or anti-bot bypass. This guide is end-to-end: setup, code, edge cases, troubleshooting.
HTTP vs SOCKS5 — which to use?
For 95% of use cases, HTTP is fine and faster. SOCKS5 wins when you need: (a) UDP traffic (gaming, custom protocols), (b) non-HTTP protocols entirely, or (c) you want DNS to be handled by the proxy (use socks5h:// for that). GProxy supports both on every product — choose by use case.
Sticky sessions explained
Default GProxy rotating residential rotates IP per request. Some workflows need to keep the same IP for a few minutes (login flows, multi-step forms). To do that, append a session token to your username:
USERNAME = 'your_user-session-abc123' # any string after -session- locks the IP for ~30 min
Same session ID = same IP. Change the ID = get a new IP.
Performance tips
- Use
requests.Session. It reuses TCP connections and is 5-10x faster for multiple requests to the same host. - Set a reasonable timeout. Default is no timeout — your script will hang forever if the proxy is slow. We recommend 15-30 seconds for residential.
- Don't load the response body if you only need the status code. Use
stream=Trueand close the connection. - Parallel requests — use
concurrent.futures.ThreadPoolExecutorfor 5-50 concurrent connections, orasyncio + httpxfor 100+.
Common pitfalls
- SSL errors on HTTPS through HTTP proxy. Add
verify=True(default) — never set False in production. If you get a cert error specifically about the proxy, ensure you're using the correct hostname. - Password contains special chars. URL-encode the password before putting it in the proxies dict:
urllib.parse.quote(password, safe=''). - requests doesn't follow proxy environment variables when proxies={} is passed. If you want env-driven config, use
trust_env=Trueon the session.
Use Cases
Web scraping at scale
Combine requests + GProxy residential rotation to scrape e-commerce sites without IP bans.
API request distribution
Use a pool of GProxy IPv6 proxies to spread API calls and avoid per-IP rate limits.
SERP monitoring
Rotate through residential proxies in different cities to track local Google rankings.
Price intelligence
Datacenter proxies for high-volume crawling of unprotected price pages.
Sneaker bot HTTP layer
Use ISP static virgin proxies (GProxy $6.50/IP virgin tier) for first attempts on sneaker drops.
Social media health checks
Single sticky residential session to verify ad delivery across geo-targeted accounts.
Use Session, not requests.get() in a loop. A single session keeps connections alive — saves 100-500ms per request.
Mix sticky and rotating sessions. Use sticky for multi-step flows (login → action → logout), rotating for stateless fetches.
Log the egress IP on errors. Add print(requests.get('https://api.ipify.org', proxies=proxies).text) at the start of each scrape to confirm rotation is working.
FAQ
Do I use http:// or https:// in the proxies dict? +
Why use socks5h:// instead of socks5://? +
Can I use the same code for residential, IPv6, and datacenter proxies? +
How do I rotate residential proxies? +
I'm getting 407 Proxy Authentication Required. +
I'm getting 'Cannot connect to proxy: tunnel connection failed: 502'. +
Does requests support HTTP/2? +
Ready to Get Started?
Start with GProxy in minutes — residential proxies from $0.85/GB, IPv6 from $0.03/proxy, pay as you go.
