summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Yick <cavemanon@mail.snootgame.xyz>2023-02-27 16:56:31 -0600
committerMichael Yick <cavemanon@mail.snootgame.xyz>2023-02-27 16:56:31 -0600
commit42f3eecc8ebcae73088fc2f02f1ede2d65c36228 (patch)
tree26036b37322f1a7cf7861b5c4e158ecd43275237
parent0f6ac43e997c04f51f161e846b38509d955eeea3 (diff)
downloaddilbertRss-42f3eecc8ebcae73088fc2f02f1ede2d65c36228.tar.gz
dilbertRss-42f3eecc8ebcae73088fc2f02f1ede2d65c36228.tar.bz2
dilbertRss-42f3eecc8ebcae73088fc2f02f1ede2d65c36228.zip
improved back off
-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)