Proxy-Session is a python module, helps to make a reliable proxy request to a HTTP server. Current version of this module is 0.0.10
Project description
Proxy-Session
Proxy-Session is a python module, helps to make a reliable proxy request to a HTTP server.
Version
The current version is 0.0.10
.
Installation
Using git
git clone https://github.com/antaripchatterjee/Proxy-Session
cd Proxy-Session
python setup.py install
Using pip
pip install Proxy-Session
Uninstallation
pip uninstall proxy_session
Platform Support
This is a cross-platform python module, provided the version of the python interpreter should be 3.6+.
API Reference
class ProxySession(requests.Session):
def __init__(self, user_=None, pass_=None, socks=False):
'''
@param user_: str[None] -> Username for proxy authentication
@param pass_: str[None] -> Password for proxy authentication
@param socks: bool[False] -> If True, it will perform a socks5
authentication, given the user_ and pass_ has been
provided. If False, it will perform a basic authent-
ication will be performed, provided the value of
user_ and pass_.
'''
super(ProxySession, self).__init__()
...
...
...
...
def make_request(self, url, method='GET', timeout=ProxySessionTimeout.SHORT_TIMEOUT, log = True, max_attempt = 100, **kwargv):
'''
@param url: str -> The target URL
@param method: str[GET] -> The HTTP method to be called
@param timeout: int[5] -> The timeout value, for the proxy request
@param log: bool[True] -> It will log the necessary information
@param max_attempt: int[100] -> Maximum number of attempt to reach the target URL,
must be a positve integer
@param **kwargv -> Other keyword arguments, which will be passed to requests.request
method
@return -> It will always return the tuple of two element, response and proxy_url
On success, it will return the reponse object, returned by the method call and
the proxy url.
On Failure after maximum attempts, it will return a Response object, having
status_code -1 with empty content. The proxy url will be null in this case.
'''
...
...
...
...
Later a better reference manual will be provided.
Usage
from proxy_session import ProxySession
from proxy_session import ProxySessionTimeout
if __name__ == '__main__':
with ProxySession() as ps:
response, proxy_addr = ps.make_request('https://httpbin.org/ip', timeout=ProxySessionTimeout.LONG_TIMEOUT, log=True)
if response.status_code == 200:
print(f'Response Content:\n{response.text}')
print(f'Proxy URL: {proxy_addr}')
else:
print("Some error occurred")
if response.status_code == -1:
print("Could not find any better proxy server")
The above code generated the below output, when I tested it.
Trying Proxy[https]: http://51.89.4.140:8118
Trying Proxy[https]: http://118.140.151.98:3128
Trying Proxy[https]: http://15.185.193.6:3128
Response Content:
{
"origin": "15.185.193.6"
}
Proxy URL: http://15.185.193.6:3128
License
Python module Proxy-Session comes with MIT License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file Proxy-Session-0.0.10.tar.gz
.
File metadata
- Download URL: Proxy-Session-0.0.10.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9013fc393f1bae0d50cdf6460efd443c39ba925185a0419cacdfe309dd06672 |
|
MD5 | eab05148bde06f260be9676d0e46cba5 |
|
BLAKE2b-256 | ee15ba7e732f525df543ec056724fde5c75c2879fc653ac6d4afa108524aa85e |
File details
Details for the file Proxy_Session-0.0.10-py3-none-any.whl
.
File metadata
- Download URL: Proxy_Session-0.0.10-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5a2dc1a828aa54679ffc7699fc8631f11229ae01927cb9ad177e9e6bdd62d55 |
|
MD5 | c17850fddb77862fc974ca77951ac12f |
|
BLAKE2b-256 | 91afd320e688bcbcda8ab3655c2713c50298e38ce1c7db99fb2d25e75e3dd4d1 |