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
None of these modules provide good support for parsing custom response headers from proxy servers. And some of them make it hard to send custom headers to proxy servers. So we at [ProxyMesh](https://proxymesh.com) made these extension modules to support our customers that use Python and want to use custom headers to control our proxy behavior. But these modules can work for handling custom headers with any proxy.
11
13
12
-
Examples for how to use these extension modules are described below.
14
+
*If you are looking for [Scrapy](https://scrapy.org/) support, please see our [scrapy-proxy-headers](https://github.com/proxymesh/scrapy-proxy-headers) project.*
15
+
16
+
## Installation
17
+
18
+
Examples for how to use these extension modules are described below. You must first do the following:
19
+
20
+
1.`pip install python-proxy-headers`
21
+
2. Install the appropriate package based on the python module you want to use.
22
+
23
+
This package does not have any dependencies because we don't know which module you want to use.
13
24
14
25
## urllib3
15
26
16
-
If you just want to send custom proxy headers, but don't need to receive proxy response headers, then you can use urllib3 directly, like so:
27
+
If you just want to send custom proxy headers, but don't need to receive proxy response headers, then you can [urllib3.ProxyManager](https://urllib3.readthedocs.io/en/stable/reference/urllib3.poolmanager.html#urllib3.ProxyManager), like so:
r = proxy.request('GET', 'https://api.ipify.org?format=json')
22
33
```
23
34
24
-
Note that when using this method, if you keep reusing the same `ProxyManager` instance, you may be re-using the proxy connection, which may have different behavior than if you create a new proxy connection for each request. For example, with ProxyMesh, you may keep getting the same IP address if you reuse the proxy connection.
35
+
Note that when using this method, if you keep reusing the same `ProxyManager` instance, you may be re-using the proxy connection, which may have different behavior than if you create a new proxy connection for each request. For example, with ProxyMesh you may keep getting the same IP address if you reuse the proxy connection.
25
36
26
37
To get proxy response headers, use our extension module like this:
27
38
@@ -32,11 +43,11 @@ r = proxy.request('GET', 'https://api.ipify.org?format=json')
32
43
r.headers['X-ProxyMesh-IP']
33
44
```
34
45
35
-
You can also pass `proxy_headers` into the`ProxyHeaderManager` as well. For example, you pass back the same `X-ProxyMesh-IP` to ensure you get the same IP address on subsequent requests.
46
+
You can also pass `proxy_headers` into our`ProxyHeaderManager` as well. For example, you can pass back the same `X-ProxyMesh-IP` header to ensure you get the same IP address on subsequent requests.
36
47
37
48
## requests
38
49
39
-
The requests adapter builds on the`urllib3_proxy_manager` module to make it easy to pass in proxy headers and receive proxy response headers.
50
+
The requests adapter builds on our`urllib3_proxy_manager` module to make it easy to pass in proxy headers and receive proxy response headers.
40
51
41
52
```python
42
53
from python_proxy_headers import requests_adapter
@@ -57,7 +68,7 @@ async with aiohttp.ClientSession() as session:
57
68
await r.text()
58
69
```
59
70
60
-
However, if you want to get proxy response, you should use our extenion module:
71
+
However, if you want to get proxy response, you should use our extension module:
61
72
62
73
```python
63
74
from python_proxy_headers import aiohttp_proxy
@@ -75,8 +86,8 @@ httpx also supports proxy headers by default, though it's not documented:
0 commit comments