Skip to content

V0.2.0 - Add Algorithms for Proxy Selection + Built-In Proxy Formatter

Choose a tag to compare

@davidteather davidteather released this 20 Sep 07:09
· 7 commits to main since this release
63e3834

🎯 Algorithm-Based Proxy Selection

  • New get_proxy() method with Random, RoundRobin, and First algorithms
  • Custom algorithm support - extend Algorithm base class for custom selection logic
  • Stateful selection - RoundRobin maintains position across calls
  from proxyproviders import Webshare
  from proxyproviders.algorithms import Random, RoundRobin

  provider = Webshare(api_key="your-key")

  # Default RoundRobin cycles through proxies
  proxy = provider.get_proxy()

  # Random selection
  proxy = provider.get_proxy(Random())

  # Reusable algorithm with state
  round_robin = RoundRobin()
  proxy1 = provider.get_proxy(round_robin)
  proxy2 = provider.get_proxy(round_robin)  # Next in sequence

🔧 Universal Proxy Formatting

  • ProxyFormat enum supporting REQUESTS, CURL, HTTPX, AIOHTTP, URL
  • proxy.format() method converts to any client format
  • One-liner requests possible
  from proxyproviders.models.proxy import ProxyFormat
  import requests

  # One-liner HTTP request through proxy
  requests.get("https://httpbin.org/ip",
              proxies=provider.get_proxy().format(ProxyFormat.REQUESTS))

  # Different formats for different clients
  proxy.format(ProxyFormat.CURL)     # ["-x", "http://user:pass@host:port"]
  proxy.format(ProxyFormat.HTTPX)    # {"http://": "...", "https://": "..."}
  proxy.format()                     # "http://user:pass@host:port" (default)

Was hoping to release this not at 2am, but got paged and can't sleep until released 😤