QuickProxy
For faster use cases where caching is not required, the swiftshadow.QuickProxy
function is the best choice. Unlike the ProxyInterface
class, QuickProxy
does not cache proxies, making it lightweight and ideal for one-off or quick operations.
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
You can use filters just like in the ProxyInterface
class. This includes filtering by country and protocol.
Parameters
countries
(list[str]): A list of two-letter country codes to filter proxies by country. Defaults to an empty list (no filtering).protocol
(Literal["http", "https"]): The protocol to filter proxies by. Defaults to"http"
.
Returns
Proxy
|None
: AProxy
object if a valid proxy is found, otherwiseNone
.
Example
from swiftshadow import QuickProxy
# Get a random HTTP proxy
proxy = QuickProxy()
print(proxy.as_string())
# Get an HTTPS proxy from the US or India
proxy = QuickProxy(countries=["US", "IN"], protocol="https")
print(proxy.as_string())
Note
Since QuickProxy
does not cache proxies, it may take slightly longer to fetch a proxy compared to ProxyInterface
when used repeatedly. However, it is faster for single-use scenarios.
Warning
If no proxies match the provided filters, QuickProxy
will return None
. Always check the return value before using it.
For more advanced use cases, such as caching and automatic rotation, consider using the ProxyInterface
class.