You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-37Lines changed: 24 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,69 +9,56 @@ Example code for using proxy servers in different programming languages. Current
9
9
10
10
## Python Proxy Examples
11
11
12
-
### Using python-proxy-headers
13
-
14
-
The [python-proxy-headers](https://github.com/proxymesh/python-proxy-headers) library enables sending custom headers to proxy servers and receiving proxy response headers. This is essential for services like [ProxyMesh](https://proxymesh.com) that use custom headers for country selection and IP assignment.
15
-
16
12
**Installation:**
17
13
18
14
```bash
19
-
pip install python-proxy-headers
15
+
pip install -r python/requirements.txt
20
16
```
21
17
22
-
**Running Examples:**
18
+
`pycurl` needs libcurl and `curl-config` (for example Debian/Ubuntu: `libcurl4-openssl-dev`). The test runner skips `pycurl-*` examples when `pycurl` is not installed, and skips `scrapy-proxy` when `import scrapy` fails (for example a broken `cryptography` / `cffi` install).
23
19
24
-
All examples read proxy configuration from environment variables:
|[cloudscraper](https://github.com/venomous/cloudscraper)|[cloudscraper-proxy-headers.py](python/cloudscraper-proxy-headers.py)| Cloudflare bypass with proxy headers |
63
-
|[autoscraper](https://github.com/alirezamika/autoscraper)|[autoscraper-proxy-headers.py](python/autoscraper-proxy-headers.py)| Automatic web scraping with proxy headers |
64
-
65
-
> **Note:** Most Python HTTP libraries do not expose custom headers on HTTPS `CONNECT` tunneling by default. These examples use [python-proxy-headers](https://github.com/proxymesh/python-proxy-headers) adapters to send proxy headers and read proxy response headers consistently.
66
-
67
-
### Basic Proxy Examples
68
-
69
-
*[requests-proxy.py](python/requests-proxy.py) - Basic proxy usage with requests
70
-
*[requests-random-proxy.py](python/requests-random-proxy.py) - Random proxy rotation
46
+
|[requests](https://docs.python-requests.org/)|[requests-proxy.py](python/requests-proxy.py)| Basic `GET` with `proxies=`|
47
+
|[requests](https://docs.python-requests.org/)|[requests-session-proxy.py](python/requests-session-proxy.py)| Session with pooled connections |
|[pycurl](http://pycurl.io/)|[pycurl-proxy.py](python/pycurl-proxy.py)| libcurl via `setopt` (`PROXY`, `WRITEDATA`, etc.) |
53
+
|[cloudscraper](https://github.com/VeNoMouS/cloudscraper)|[cloudscraper-proxy.py](python/cloudscraper-proxy.py)| Requests-based scraper with `proxies`|
54
+
|[autoscraper](https://github.com/alirezamika/autoscraper)|[autoscraper-proxy.py](python/autoscraper-proxy.py)| Offline `html=` demo (matches upstream tests); README shows `request_args` + `proxies` for live URLs |
55
+
|[Scrapy](https://scrapy.org/)|[scrapy-proxy.py](python/scrapy-proxy.py)|`scrapy runspider` with `meta['proxy']`|
56
+
57
+
### Other Python scripts
71
58
72
-
### Scrapy
59
+
*[requests-random-proxy.py](python/requests-random-proxy.py) - Random proxy rotation
73
60
74
-
*[scrapy-proxy-headers.py](python/scrapy-proxy-headers.py) - Scrapy spider with proxyheaders
61
+
> **Note:** Like the Ruby, JavaScript, and PHP examples here, these scripts use each library's normal proxy options only. Most of them do not send custom headers on the HTTPS `CONNECT` tunnel or surface proxy `CONNECT` response headers. For that, see [python-proxy-headers](https://github.com/proxymesh/python-proxy-headers) or [scrapy-proxy-headers](https://github.com/proxymesh/scrapy-proxy-headers).
0 commit comments