Skip to content

alenkimov/better_proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
    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

More libraries of the family:

aiohttp

import aiohttp
from better_proxy import Proxy
from aiohttp_socks import ProxyConnector

proxy = Proxy.from_str("socks5://user:[email protected]: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)
    ...

About

Better proxy!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages