Guest User

Untitled

a guest
Aug 14th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. import requests
  2. from requests.adapters import HTTPAdapter
  3. from requests.packages.urllib3.util.retry import Retry
  4.  
  5. def curl_page(url):
  6. session = requests.Session()
  7. retry = Retry(connect=3, backoff_factor=0.3, total=10, redirect=5)
  8. adapter = HTTPAdapter(max_retries=retry)
  9. session.mount('http://', adapter)
  10. session.mount('https://', adapter)
  11. try:
  12. return session.get(url)
  13. except Exception as err:
  14. print('Error accessing the URL:',url)
  15. traceback.print_exc()
Add Comment
Please, Sign In to add comment