diff options
Diffstat (limited to 'main.py')
-rwxr-xr-x | main.py | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -1,9 +1,10 @@ #!/usr/bin/env python3 import requests +from requests.adapters import HTTPAdapter +from urllib3.util.retry import Retry import bs4 import time import feedgenerator -import json from datetime import datetime, timedelta from fastapi import FastAPI, Response @@ -21,6 +22,15 @@ async def root(): for day in range(0,7): rawDate = datetime.today() - timedelta(days = day) date = rawDate.strftime('%Y-%m-%d') + + session = requests.Session() + retry = Retry(connect=3, backoff_factor=0.5) + adapter = HTTPAdapter(max_retries=retry) + session.mount('http://', adapter) + session.mount('https://', adapter) + + session.get("https://dilbert.com/strip/" + date) + tries = 25 for i in range(tries): search = requests.get("https://dilbert.com/strip/" + date) |