set user-agent to support new abfall.io api with generic ics

This commit is contained in:
mampfes
2020-05-03 08:38:44 +02:00
parent 97547ca6ad
commit 944b7d8c7b

View File

@@ -15,11 +15,20 @@ TEST_CASES = OrderedDict(
{
"url": "https://www.avl-ludwigsburg.de/fileadmin/Files/Abfallkalender/ICS/Privat/Privat_{%Y}_Ossweil.ics"
},
)
),
(
"Esslingen, Bahnhof",
{
"url": "https://api.abfall.io/?kh=DaA02103019b46345f1998698563DaAd&t=ics&s=1a862df26f6943997cef90233877a4fe"
},
),
]
)
HEADERS = {"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"}
class Source:
def __init__(self, url):
self.url = url
@@ -40,7 +49,7 @@ class Source:
def fetch_year(self, url):
# get ics file
r = requests.get(url)
r = requests.get(url, headers=HEADERS)
r.encoding = "utf-8" # requests doesn't guess the encoding correctly
entries = []