Created
June 20, 2019 13:47
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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