proxy_scraper/example.py

14 lines
372 B
Python

import requests
from requests.adapters import HTTPAdapter, Retry
proxies = {'https': 'http://localhost:8080', 'http': 'http://localhost:8080'}
s = requests.Session()
retries = Retry(total=5, backoff_factor=1, status_forcelist=[ 502, 503, 504 ])
s.mount('http://', HTTPAdapter(max_retries=retries))
s.proxies = proxies
ip = s.get('http://canhasip.com/')
print(ip.text)