fix: Add a fake user agent

master
Abdussamet Kocak 4 years ago
parent f31f0def29
commit 5b4c818451

@ -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()

Loading…
Cancel
Save