diff options
author | Michael Yick <cavemanon@mail.snootgame.xyz> | 2023-02-27 16:56:31 -0600 |
---|---|---|
committer | Michael Yick <cavemanon@mail.snootgame.xyz> | 2023-02-27 16:56:31 -0600 |
commit | 42f3eecc8ebcae73088fc2f02f1ede2d65c36228 (patch) | |
tree | 26036b37322f1a7cf7861b5c4e158ecd43275237 /main.py | |
parent | 0f6ac43e997c04f51f161e846b38509d955eeea3 (diff) | |
download | dilbertRss-42f3eecc8ebcae73088fc2f02f1ede2d65c36228.tar.gz dilbertRss-42f3eecc8ebcae73088fc2f02f1ede2d65c36228.tar.bz2 dilbertRss-42f3eecc8ebcae73088fc2f02f1ede2d65c36228.zip |
improved back off
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) |