Requests Library
swiftshadow
integrates seamlessly with the popular requests
library, allowing you to easily route your HTTP/HTTPS requests through a proxy.
Example Usage
Here’s how you can use a proxy fetched by QuickProxy
with the requests
library:
from swiftshadow import QuickProxy
from requests import get
# Fetch a proxy
proxy = QuickProxy()
# Use the proxy with requests
resp = get('https://checkip.amazonaws.com', proxies=proxy.as_requests_dict())
print(resp.text)
Explanation
QuickProxy
fetches a proxy object.- The
as_requests_dict()
method converts the proxy into a format compatible with therequests
library. - The
proxies
parameter inrequests.get()
is used to route the request through the proxy.
Note
If the proxy is working correctly, the output should be an IPv4
address that is not your own.
For more advanced use cases, such as caching and automatic rotation, consider using the ProxyInterface
class. For additional details, visit the References page.