Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from requests.adapters import HTTPAdapter
- from requests.packages.urllib3.util.retry import Retry
- def curl_page(url):
- session = requests.Session()
- retry = Retry(connect=3, backoff_factor=0.3, total=10, redirect=5)
- adapter = HTTPAdapter(max_retries=retry)
- session.mount('http://', adapter)
- session.mount('https://', adapter)
- try:
- return session.get(url)
- except Exception as err:
- print('Error accessing the URL:',url)
- traceback.print_exc()
Add Comment
Please, Sign In to add comment