Skip to content

Instantly share code, notes, and snippets.

@JasonCrowe
Created June 20, 2019 13:47
Show Gist options
  • Save JasonCrowe/4673c5b43ebba9da1cd303b748980895 to your computer and use it in GitHub Desktop.
Save JasonCrowe/4673c5b43ebba9da1cd303b748980895 to your computer and use it in GitHub Desktop.
Simple way to use a proxy api (high quantity, low quality proxies) reliably.
def get_proxy():
api_key = ''
proxy_url = f'https://api.getproxylist.com/proxy?apiKey={api_key}&lastTested=600&protocol[]=http&allowsHttps=1&minDownloadSpeed=500&maxConnectTime=1'
p = requests.get(proxy_url).json()
return f"{p['protocol']}://{p['ip']}:{p['port']}"
def get_lender():
while True:
try:
r = requests.get(
f'https://api.zxy.org/v1/lenders/xyz.json',
proxies={"https": get_proxy()},
timeout=3
)
except Exception:
continue
if r.status_code == 200:
break
return r.json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment