Skip to main content

Better Proxy

Telegram channel PyPI version info PyPI supported Python versions PyPI downloads per month

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

Playwright: http proxy

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

Metadata

Release files for better-proxy 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for better-proxy 1.3.1
File Size Uploaded Provenance Actions
better_proxy-1.3.1.tar.gz 4.1 kB Without provenance Details for better_proxy-1.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for better-proxy 1.3.1
File Interpreter ABI Platform Actions
better_proxy-1.3.1-py3-none-any.whl Python 3 none any Details for better_proxy-1.3.1-py3-none-any.whl

Total release size: 8.4 kB

Release files / better_proxy-1.3.1.tar.gz

Download URL better_proxy-1.3.1.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3248381a35b862638d32de31426dfb8653fd82bebbe21549858df8a0f6d2b752
BLAKE2b-256 checksum
How to use checksums
3188a4ee2d3f873dd21c2708362ccdf877e7d26588e3021d9e6c2d62a004b213
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Windows/11

Release files / better_proxy-1.3.1-py3-none-any.whl

Download URL better_proxy-1.3.1-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cfa9169b553c25c18a3d5397dd1295fca8efbac5bf48b69f7b16423ba5056940
BLAKE2b-256 checksum
How to use checksums
00460c8c8d5026121f36c6e110f411044d5e6da877136bfd071350cdbd39c0f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Windows/11

Security for better-proxy 1.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page