Skip to content

Using QuickProxy

For faster use cases where caching is not required swiftshadow.QuickProxy function is the best choice.

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

Parameters:

Name Type Description Default
countries list

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

[]
protocol str

HTTP/HTTPS protocol to filter proxies.

'http'

Returns:

Name Type Description
proxyObject dict

A working proxy object.

Source code in swiftshadow/__init__.py
def QuickProxy(countries: list = [], protocol: str = "http"):
    """
    This function is a faster alternative to `Proxy` 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 (dict): A working proxy object.
    """
    for providerDict in Providers:
        if protocol not in providerDict["protocols"]:
            continue
        if (len(countries) != 0) and (not providerDict["countryFilter"]):
            continue
        try:
            return providerDict["provider"](1, countries, protocol)[0]
        except:
            continue
    return None

You can use filters just like in swiftshadow.Proxy class.

Example

from swiftshadow import QuickProxy

print(QuickProxy())