Skip to main content

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.9

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.9.

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

Proxy-Session-0.0.9.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

Proxy_Session-0.0.9-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file Proxy-Session-0.0.9.tar.gz.

File metadata

  • Download URL: Proxy-Session-0.0.9.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

Hashes for Proxy-Session-0.0.9.tar.gz
Algorithm Hash digest
SHA256 3758a759ca5b297620e20d7036da678a5e1dcd5f7fb548cd96fc49fb59c9e88d
MD5 04a01fba70def09f0adbcc85ec3da032
BLAKE2b-256 830beb1c12604fb0069ab22fee2f49c022ebe9aafdf7ec4223c59b9e95858313

See more details on using hashes here.

File details

Details for the file Proxy_Session-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: Proxy_Session-0.0.9-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

Hashes for Proxy_Session-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 c3c49282914eecfe92d193afe51a854fc6e6359514dc3abf28680497915d3f98
MD5 eb890d276ca876c19e1a6f5c687cbdbf
BLAKE2b-256 cb15d3e8d5082b1cf7517eb5fbe02847d0840852ef5eb7e094b10740b7f6347a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page