Spaces:
Sleeping
Sleeping
import requests | |
import random | |
PROXY_URL = 'https://raw.githubusercontent.com/jetkai/proxy-list/main/online-proxies/json/proxies.json' | |
# Fetch the list of proxies | |
def getProxy(): | |
response = requests.get(PROXY_URL, timeout=5) | |
# Check if the request was successful | |
if response.status_code == 200: | |
proxies = (response.json())["https"] | |
# Select a random list of 5 from the list | |
random_proxylist = random.sample(proxies, 10) | |
# Print the selected proxy | |
return random_proxylist | |
else: | |
print(f"Error {response.status_code}: Could not retrieve proxy list.") | |
getProxy() | |