From 5b4c8184510da2145051f9f5c5be62f71e3b5e62 Mon Sep 17 00:00:00 2001 From: Abdussamet Kocak Date: Sun, 27 Feb 2022 15:57:37 +0300 Subject: [PATCH] fix: Add a fake user agent --- core/diyanet.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/diyanet.py b/core/diyanet.py index b3eae48..f2d782e 100644 --- a/core/diyanet.py +++ b/core/diyanet.py @@ -8,7 +8,13 @@ from aiocache import cached, Cache from bs4 import BeautifulSoup from pydantic import BaseModel -_http = httpx.AsyncClient(timeout=20, follow_redirects=True) +_http = httpx.AsyncClient( + timeout=20, + follow_redirects=True, + headers={ + 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:98.0) Gecko/20100101 Firefox/98.0' + } +) class PrayerTimes(BaseModel): @@ -21,7 +27,7 @@ class PrayerTimes(BaseModel): isha: str -@cached(ttl=3*60*60, cache=Cache.MEMORY) +@cached(ttl=3 * 60 * 60, cache=Cache.MEMORY) async def parse_prayer_times(url: str) -> List[PrayerTimes]: res = await _http.get(url) res.raise_for_status()