Metadata-Version: 2.2
Name: proxy-handler
Version: 1.0.0
Summary: simple proxy class
Author-email: olezx <olekzx@python.com>
Project-URL: Homepage, https://github.com/olekzx/proxy-handler
Project-URL: Bug Tracker, https://github.com/olekzx/proxy-handler/issues
Keywords: python,proxy,socks5,https,http,requests,httpx,async
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.27.0

# proxy-handler
A simple proxy class with built-in support for proxy authentication and connection testing

## Installation

    pip install proxy-handler

## Examples

#### Create a proxy

```python
from proxy import Proxy, ProxyType

# Proxy without authentication
proxy = Proxy.from_host_colon_port("host:port", ProxyType.SOCKS5)

# Proxy with authentication
proxy2 = Proxy.from_host_port_colon_user_pass("host:port:user:pass", ProxyType.HTTP)
```

#### Check connection

```python
from proxy import Proxy, ProxyType
import asyncio

proxy = Proxy.from_host_colon_port("host:port", ProxyType.SOCKS5)

# check_connection is an async method, so we use asyncio.run()
connection = asyncio.run(proxy.check_connection())

print(connection)
```

#### Flexible formats

```python
from proxy import Proxy, ProxyType
import asyncio

proxy = Proxy.from_host_colon_port("host:port", ProxyType.SOCKS5)

proxy.host_at_port() # e.g., 'socks5://host@port'
proxy.host_colon_port() # e.g., 'socks5://host:port'
proxy.host_port_at_user_pass() # e.g., 'socks5://host:port@user:pass'
```

#### Error handling

```python
from proxy import Proxy, ProxyType, InvalidProxyFormatException

try:
    proxy = Proxy.from_host_colon_port("host@port", ProxyType.SOCKS5)
except InvalidProxyFormatException as e:
    print(f"Error - {e}")

```


This project, **proxy-handler**, is licensed under the MIT License.  
See the [LICENSE](./LICENSE) file for details.
