Skip to content

V0.1.1 - Initial Release With Support for WebShare, BrightData

Choose a tag to compare

@davidteather davidteather released this 18 Feb 03:12
· 16 commits to main since this release

Welcome to the start of this new project! This project provides an easy to use interface for interacting with many different proxy providers under the hood through the ProxyProvider abstraction.

I intend to integrate this into the TikTokAPI repository within the next few weeks to allow people to use existing and develop their own proxy providers through this.

Here's a quick example of the shared abstraction if anyone's just looking at the release and not the docs

from proxyproviders import Webshare, BrightData, ProxyProvider
import requests
import os


def request_with_proxy(provider: ProxyProvider):
    requests_proxy = None
    if provider:
        proxies = provider.list_proxies()
        requests_proxy = {
            "http": f"http://{proxies[0].username}:{proxies[0].password}@{proxies[0].proxy_address}:{proxies[0].port}",
            "https": f"http://{proxies[0].username}:{proxies[0].password}@{proxies[0].proxy_address}:{proxies[0].port}",
        }
    r = requests.get("https://httpbin.org/ip", proxies=requests_proxy)
    return r.json()

webshare = Webshare(api_key=os.getenv("WEBSHARE_API_KEY"))
brightdata = BrightData(api_key=os.getenv("BRIGHTDATA_API_KEY"), zone="my_zone")

print(f"Your IP: {request_with_proxy(None)}")
print(f"Webshare: {request_with_proxy(webshare)}")
print(f"BrightData: {request_with_proxy(brightdata)}")
==================================================================================================== test session starts =====================================================================================================
platform darwin -- Python 3.11.2, pytest-8.3.4, pluggy-1.5.0
configfile: pyproject.toml
collected 21 items                                                                                                                                                                                                           

tests/integration/test_brightdata_integration.py .                                                                                                                                                                     [  4%]
tests/integration/test_webshare_integration.py .                                                                                                                                                                       [  9%]
tests/providers/test_brightdata.py ......                                                                                                                                                                              [ 38%]
tests/providers/test_webshare.py .......                                                                                                                                                                               [ 71%]
tests/test_exceptions.py ..                                                                                                                                                                                            [ 80%]
tests/test_proxy_provider.py ....                                                                                                                                                                                      [100%]

===================================================================================================== 21 passed in 2.57s =====================================================================================================
Name                                     Stmts   Miss Branch BrPart  Cover
--------------------------------------------------------------------------
proxyproviders/__init__.py                   5      0      0      0   100%
proxyproviders/exceptions.py                16      0      0      0   100%
proxyproviders/models/__init__.py            0      0      0      0   100%
proxyproviders/models/proxy.py              23      0      0      0   100%
proxyproviders/providers/brightdata.py      53      2     10      1    95%
proxyproviders/providers/webshare.py        46      0      6      0   100%
proxyproviders/proxy_provider.py            38      1      8      0    98%
--------------------------------------------------------------------------
TOTAL                                      181      3     24      1    98%