# Better Proxy
[](https://t.me/cum_insider)
[](https://pypi.python.org/pypi/better-proxy)
[](https://pypi.python.org/pypi/better-proxy)
[](https://pypi.python.org/pypi/better-proxy)
Proxy as a class
- The `Proxy.from_str()` method supports most proxy formats (with and without protocol):
```
host:port:login:password
host:port@login:password
login:password@host:port
login:password:host:port
host:port
```
- The `Proxy.from_file()` method returns the list of proxies from the file at the specified path
```bash
pip install better-proxy
```
## aiohttp
```python
import aiohttp
from better_proxy import Proxy
from aiohttp_socks import ProxyConnector
proxy = Proxy.from_str("socks5://user:password@127.0.0.1:1080")
async def fetch(url):
connector = ProxyConnector.from_url(proxy.as_url)
async with aiohttp.ClientSession(connector=connector) as session:
async with session.get(url) as response:
return await response.text()
```
## requests
```python
import requests
from better_proxy import Proxy
proxy = Proxy.from_str("http://user:password@host:port")
def fetch(url):
response = requests.get(url, proxies=proxy.as_proxies_dict)
return response.text
```
## playwright
[Playwright: http proxy](https://playwright.dev/python/docs/network#http-proxy)
```python
from playwright.async_api import async_playwright, Playwright
from better_proxy import Proxy
proxy = Proxy.from_str("http://user:password@host:port")
async def fetch(playwright: Playwright, url):
chromium = playwright.chromium
browser = await chromium.launch(proxy=proxy.as_playwright_proxy)
...
```
## httpx
```python
import httpx
from better_proxy import Proxy
proxy = Proxy.from_str("login:password@210.173.88.77:3001")
async def fetch(url):
async with httpx.AsyncClient(proxy=proxy.as_url) as client:
response = await client.get(url)
return response.text
```
## httpx-socks
```python
import httpx
from httpx_socks import AsyncProxyTransport
from better_proxy import Proxy
proxy = Proxy.from_str("socks5://login:password@210.173.88.77:3001")
async def fetch(url):
transport = AsyncProxyTransport.from_url(proxy.as_url)
async with httpx.AsyncClient(transport=transport) as client:
response = await client.get(url)
return response.text
```
Raw data
{
"_id": null,
"home_page": "https://github.com/alenkimov/better_proxy",
"name": "better-proxy",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Alen",
"author_email": "alen.kimov@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/31/88/a4ee2d3f873dd21c2708362ccdf877e7d26588e3021d9e6c2d62a004b213/better_proxy-1.3.1.tar.gz",
"platform": null,
"description": "# Better Proxy\n[](https://t.me/cum_insider)\n[](https://pypi.python.org/pypi/better-proxy)\n[](https://pypi.python.org/pypi/better-proxy)\n[](https://pypi.python.org/pypi/better-proxy)\n\nProxy as a class\n\n- The `Proxy.from_str()` method supports most proxy formats (with and without protocol):\n ```\n host:port:login:password\n host:port@login:password\n login:password@host:port\n login:password:host:port\n host:port\n ```\n- The `Proxy.from_file()` method returns the list of proxies from the file at the specified path\n\n\n```bash\npip install better-proxy\n```\n\n## aiohttp\n```python\nimport aiohttp\nfrom better_proxy import Proxy\nfrom aiohttp_socks import ProxyConnector\n\nproxy = Proxy.from_str(\"socks5://user:password@127.0.0.1:1080\")\n\nasync def fetch(url):\n connector = ProxyConnector.from_url(proxy.as_url)\n \n async with aiohttp.ClientSession(connector=connector) as session:\n async with session.get(url) as response:\n return await response.text()\n```\n\n## requests\n```python\nimport requests\nfrom better_proxy import Proxy\n\nproxy = Proxy.from_str(\"http://user:password@host:port\") \n\ndef fetch(url):\n response = requests.get(url, proxies=proxy.as_proxies_dict) \n return response.text\n```\n\n## playwright\n[Playwright: http proxy](https://playwright.dev/python/docs/network#http-proxy)\n\n```python\nfrom playwright.async_api import async_playwright, Playwright\nfrom better_proxy import Proxy\n\nproxy = Proxy.from_str(\"http://user:password@host:port\")\n\nasync def fetch(playwright: Playwright, url):\n chromium = playwright.chromium\n browser = await chromium.launch(proxy=proxy.as_playwright_proxy)\n ...\n```\n\n## httpx\n```python\nimport httpx\nfrom better_proxy import Proxy\n\nproxy = Proxy.from_str(\"login:password@210.173.88.77:3001\")\n\nasync def fetch(url):\n async with httpx.AsyncClient(proxy=proxy.as_url) as client:\n response = await client.get(url)\n return response.text\n```\n\n## httpx-socks\n```python\nimport httpx\nfrom httpx_socks import AsyncProxyTransport\nfrom better_proxy import Proxy\n\nproxy = Proxy.from_str(\"socks5://login:password@210.173.88.77:3001\")\n\nasync def fetch(url):\n transport = AsyncProxyTransport.from_url(proxy.as_url)\n async with httpx.AsyncClient(transport=transport) as client:\n response = await client.get(url)\n return response.text\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Better proxy!",
"version": "1.3.1",
"project_urls": {
"Homepage": "https://github.com/alenkimov/better_proxy",
"Repository": "https://github.com/alenkimov/better_proxy",
"Source": "https://github.com/alenkimov/better_proxy"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "00460c8c8d5026121f36c6e110f411044d5e6da877136bfd071350cdbd39c0f1",
"md5": "249367b961681aa7824e2a2eca13ea71",
"sha256": "cfa9169b553c25c18a3d5397dd1295fca8efbac5bf48b69f7b16423ba5056940"
},
"downloads": -1,
"filename": "better_proxy-1.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "249367b961681aa7824e2a2eca13ea71",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 4325,
"upload_time": "2024-12-31T03:01:08",
"upload_time_iso_8601": "2024-12-31T03:01:08.651997Z",
"url": "https://files.pythonhosted.org/packages/00/46/0c8c8d5026121f36c6e110f411044d5e6da877136bfd071350cdbd39c0f1/better_proxy-1.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3188a4ee2d3f873dd21c2708362ccdf877e7d26588e3021d9e6c2d62a004b213",
"md5": "60f97b2f7092865a3457bfb760042c2b",
"sha256": "3248381a35b862638d32de31426dfb8653fd82bebbe21549858df8a0f6d2b752"
},
"downloads": -1,
"filename": "better_proxy-1.3.1.tar.gz",
"has_sig": false,
"md5_digest": "60f97b2f7092865a3457bfb760042c2b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 4060,
"upload_time": "2024-12-31T03:01:10",
"upload_time_iso_8601": "2024-12-31T03:01:10.583885Z",
"url": "https://files.pythonhosted.org/packages/31/88/a4ee2d3f873dd21c2708362ccdf877e7d26588e3021d9e6c2d62a004b213/better_proxy-1.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-31 03:01:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "alenkimov",
"github_project": "better_proxy",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "better-proxy"
}