cgiproxy-20.11.14


توضیحات

The simple HTTP proxy.
ویژگی مقدار
سیستم عامل -
نام فایل cgiproxy-20.11.14
نام cgiproxy
نسخه کتابخانه 20.11.14
نگهدارنده []
ایمیل نگهدارنده []
نویسنده Valentin Podkamennyi, Alex Krailo
ایمیل نویسنده -
آدرس صفحه اصلی https://github.com/Datamart/CGI-Proxy
آدرس اینترنتی https://pypi.org/project/cgiproxy/
مجوز Apache 2.0
# CGI Proxy [![Build Status](https://travis-ci.org/Datamart/CGI-Proxy.svg?branch=master)](https://travis-ci.org/Datamart/CGI-Proxy) [![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) [![PyPI Version](https://img.shields.io/pypi/v/cgiproxy.svg)](https://pypi.org/project/cgiproxy/) [![Python Versions](https://img.shields.io/pypi/pyversions/cgiproxy.svg)](https://pypi.org/project/cgiproxy/) [![PyPI Downloads](https://img.shields.io/pypi/dm/cgiproxy.svg?style=flat)](https://pypi.org/project/cgiproxy/) [![PyPI Format](https://img.shields.io/pypi/format/cgiproxy.svg?style=flat)](https://pypi.org/project/cgiproxy/) [![PyPI Status](https://img.shields.io/pypi/status/cgiproxy.svg?style=flat)](https://pypi.org/project/cgiproxy/) Simple CGI HTTP Proxy. * Sets the `X-Forwarded-For` header with the client IP address; * Sets the `User-Agent` header with the client' `User-Agent` string; * Decodes `gzip`-ed content; * Prints all errors to `stderr`; * Uses `urllib2` for Python 2 and `urllib.request` for Python 3. ## Installation Install from PyPI using `pip`: ```bash $ pip install cgiproxy ``` ## Methods ### do_get(url, headers=None) Performs `GET` request. **Arguments:** * `url` - The request URL as `str`. * `headers` - Optional HTTP request headers as `dict`. **Returns:** * A tuple of `(content, status_code, response_headers)` ### do_head(url, headers=None) Performs `HEAD` request. **Arguments:** * `url` - The request URL as `str`. * `headers` - Optional HTTP request headers as `dict`. **Returns:** * A tuple of `(content='', status_code, response_headers)` ### do_post(url, data=None, headers=None) Performs `POST` request. Converts query to `POST` params if `data` is `None`. **Arguments:** * `url` - The request URL as `str`. * `data` - Optional HTTP POST data as URL-encoded `str`. * `headers` - Optional HTTP request headers as `dict`. **Returns:** * A tuple of `(content, status_code, response_headers)` ### get_http_status(url, headers=None) Gets HTTP status code. **Arguments:** * `url` - The request URL as `str`. * `headers` - Optional HTTP request headers as `dict`. **Returns:** * An HTTP status code. ### get_response_headers(url, headers=None) Gets HTTP response headers. **Arguments:** * `url` - The request URL as `str`. * `headers` - Optional HTTP request headers as `dict`. **Returns:** * An HTTP response headers as `dict`. ## Examples ```python import cgiproxy status = cgiproxy.get_http_status('https://www.pageportrait.com/') print(200 == status) headers = cgiproxy.get_response_headers('https://komito.net/') print(headers.get('content-type')) content, status, headers = cgiproxy.do_head('https://www.dtm.io/') print('' == content) print(200 == status) print(headers.get('content-type')) content, status, headers = cgiproxy.do_get('https://www.dtm.io/', headers={ 'User-Agent': 'Mozilla/5.0 (compatible; Darwin/18.2.0) cgiproxy/18.12', 'X-Custom-Header': 'value' }) print('' != content) print(200 == status) print(headers.get('content-type')) content, status, headers = cgiproxy.do_post('https://example.com/', data='aaa%3Dbbb%26ccc%3Dddd') print('' != content) print(200 == status) print(headers.get('content-type')) ```


نحوه نصب


نصب پکیج whl cgiproxy-20.11.14:

    pip install cgiproxy-20.11.14.whl


نصب پکیج tar.gz cgiproxy-20.11.14:

    pip install cgiproxy-20.11.14.tar.gz