Better proxy!
Project description
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
pip install better-proxy
aiohttp
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
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
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
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
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
better_proxy-1.3.1.tar.gz
(4.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file better_proxy-1.3.1.tar.gz.
File metadata
- Download URL: better_proxy-1.3.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3248381a35b862638d32de31426dfb8653fd82bebbe21549858df8a0f6d2b752
|
|
| MD5 |
60f97b2f7092865a3457bfb760042c2b
|
|
| BLAKE2b-256 |
3188a4ee2d3f873dd21c2708362ccdf877e7d26588e3021d9e6c2d62a004b213
|
File details
Details for the file better_proxy-1.3.1-py3-none-any.whl.
File metadata
- Download URL: better_proxy-1.3.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfa9169b553c25c18a3d5397dd1295fca8efbac5bf48b69f7b16423ba5056940
|
|
| MD5 |
249367b961681aa7824e2a2eca13ea71
|
|
| BLAKE2b-256 |
00460c8c8d5026121f36c6e110f411044d5e6da877136bfd071350cdbd39c0f1
|