summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmain.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/main.py b/main.py
index be64396..10efd18 100755
--- a/main.py
+++ b/main.py
@@ -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)