Skip to content

QuickProxy Class

swiftshadow.QuickProxy(countries=[], protocol='http')

This function is a faster alternative to ProxyInterface class. No caching is done.

Parameters:

Name Type Description Default
countries list[str]

ISO 3166-2 Two letter country codes to filter proxies.

[]
protocol Literal['http', 'https']

HTTP/HTTPS protocol to filter proxies.

'http'

Returns:

Name Type Description
proxyObject Proxy

A working proxy object if found or else None.

Source code in swiftshadow/__init__.py
def QuickProxy(
    countries: list[str] = [], protocol: Literal["http", "https"] = "http"
) -> Proxy | None:
    """
    This function is a faster alternative to `ProxyInterface` class.
    No caching is done.

    Args:
        countries: ISO 3166-2 Two letter country codes to filter proxies.
        protocol: HTTP/HTTPS protocol to filter proxies.

    Returns:
        proxyObject (Proxy): A working proxy object if found or else None.
    """
    for provider in Providers:
        if protocol not in provider.protocols:
            continue
        if (len(countries) != 0) and (not provider.countryFilter):
            continue
        try:
            return run(provider.providerFunction(countries, protocol))[0]
        except Exception:
            continue
    return None