A quick guide to using QG.net (青果网络) tunnel proxy in Python for web scraping with automatic IP rotation.
QG.net provides residential proxy services in China. The tunnel proxy mode automatically rotates your IP address on every request — no manual IP management needed.
Official docs:
- Tunnel proxy: https://www.qg.net/doc/1879.html
- Exclusive proxy: https://www.qg.net/doc/use/8_244/1802.html
Sign up at qg.net and purchase a tunnel proxy plan. You'll receive:
- Authkey — your authentication key
- Authpwd — your authentication password
- Address — tunnel server (e.g.
tun-xxxxx.qg.net:12345)
cp .env.example .envEdit .env with your credentials:
TUNNEL_PROXY_URL=http://YOUR_AUTHKEY:YOUR_AUTHPWD@tun-xxxxx.qg.net:PORT
pip install requestspython example.pyThe tunnel proxy URL format is:
http://AUTHKEY:AUTHPWD@SERVER:PORT
Pass it as both http and https proxy to requests:
proxies = {
"http": "http://AUTHKEY:AUTHPWD@tun-xxxxx.qg.net:12345",
"https": "http://AUTHKEY:AUTHPWD@tun-xxxxx.qg.net:12345",
}
response = requests.get("https://httpbin.org/ip", proxies=proxies)Each request automatically gets a fresh Chinese IP address (普通模式: 每次请求都自动切换IP).
Connection: close— Add this header so each request gets a new connection (and new IP):headers = {"Connection": "close"}
- Don't use
requests.Sessionwith some sites — sessions reuse connections, which may bypass IP rotation or trigger blocks. Use rawrequests.get()if you encounter issues. - Rate limiting — Add
time.sleep(2)between requests to avoid triggering target site rate limits. - Error
-11(请求过于频繁) — You're calling the proxy API too fast. Back off 15-30 seconds.
| File | Purpose |
|---|---|
example.py |
Sample script demonstrating tunnel proxy usage |
.env.example |
Template for proxy credentials |
.gitignore |
Keeps .env out of git |