Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Use WeProxy with Python

WeProxy — Python proxy example

Website Python Integrations

Automate egress through WeProxy with the standard requests library — the default choice for Python scrapers, notebooks, and ETL jobs.


What you get

A single script that:

  • Builds http://USER:PASS@gw.weproxy.com.tr:8989
  • Passes it as both http and https entries in proxies=
  • Hits an IP echo URL and prints the exit address

Ideal as a connectivity canary before you wire WeProxy into Scrapy, httpx, or custom crawlers.

Requirements

Install

python -m venv .venv
# Windows:
.venv\Scripts\activate
# macOS/Linux:
# source .venv/bin/activate

pip install -r requirements.txt
cp .env.example .env

Export credentials (the sample reads the process environment, not the file parser):

export WEPROXY_USER="your-user"
export WEPROXY_PASS="your-pass"

PowerShell:

$env:WEPROXY_USER="your-user"
$env:WEPROXY_PASS="your-pass"

Run

python src/check_ip.py

Core snippet

import requests

proxy = "http://USER:PASSWORD@gw.weproxy.com.tr:8989"
proxies = {"http": proxy, "https": proxy}

print(requests.get("https://api.ipify.org", proxies=proxies, timeout=30).text)

Env-aware version: src/check_ip.py.

Patterns beyond the demo

Use case Hint
Session reuse requests.Session() + same proxies dict
Retries Wrap with urllib3 Retry or tenacity; treat 407 as auth bug
Async httpx / aiohttp with proxy URL — same gateway string
Scrapy Set http_proxy / middleware auth from panel secrets
SOCKS5 Needs requests[socks] and a SOCKS-enabled package

Product line (residential vs datacenter) changes credentials, not the Python API. Compare on Pricing and Rotating residential.

Troubleshooting

Symptom Likely cause
ProxyError Bad host/port, network path, or suspended package
407 Wrong user/pass
Hangs Raise timeout=; free proxies hang — paid gateway should not
Different IP each run Expected on rotating packages

cURL sanity check:

curl -x http://USER:PASSWORD@gw.weproxy.com.tr:8989 https://api.ipify.org

Project layout

python-proxy/
├── assets/banner.png
├── src/check_ip.py
├── requirements.txt
├── .env.example
└── README.md

Related

License

MIT — see LICENSE.

About

Python requests + WeProxy HTTP proxy example for scraping and automation

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages