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

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

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.11.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: Proxy-Session-0.0.11.tar.gz
  • Upload date:
  • Size: 5.6 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.11.tar.gz
Algorithm Hash digest
SHA256 fe0506c18ec0fdf8398fec8b932235e9ec7b1f7834afa73bf940919983b0cd34
MD5 006c889bc256e499d8a67098cf013f62
BLAKE2b-256 2c093f465dbe0ca0edc89762a9e064957cb69a6180371139c43ad5b5a457b56a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: Proxy_Session-0.0.11-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.11-py3-none-any.whl
Algorithm Hash digest
SHA256 d1851807d5888b1444cd7a3f3543b26b599b7ee8cd0feee453e0e457134d2238
MD5 3ad1e290b1f12f6156bc30994eb8ea31
BLAKE2b-256 9f6c2b524185030a79cf7d36d636fd5c4253a320112d99cc4d67b223a2e3fa50

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