Skip to main content

Better proxy!

Project description

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

Project details


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

better_proxy-1.3.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

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

Hashes for better_proxy-1.3.1.tar.gz
Algorithm Hash digest
SHA256 3248381a35b862638d32de31426dfb8653fd82bebbe21549858df8a0f6d2b752
MD5 60f97b2f7092865a3457bfb760042c2b
BLAKE2b-256 3188a4ee2d3f873dd21c2708362ccdf877e7d26588e3021d9e6c2d62a004b213

See more details on using hashes here.

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

Hashes for better_proxy-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cfa9169b553c25c18a3d5397dd1295fca8efbac5bf48b69f7b16423ba5056940
MD5 249367b961681aa7824e2a2eca13ea71
BLAKE2b-256 00460c8c8d5026121f36c6e110f411044d5e6da877136bfd071350cdbd39c0f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page