From b7bf1d8c9824b550c237a4d831cf7e15b054fc06 Mon Sep 17 00:00:00 2001 From: Abdussamet Kocak Date: Fri, 31 Mar 2023 16:41:16 +0200 Subject: [PATCH] fix: Ignore new Hijri date column on the page --- core/diyanet.py | 16 ++++++++++------ requirements.txt | 5 +++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/core/diyanet.py b/core/diyanet.py index f2d782e..4b87f3b 100644 --- a/core/diyanet.py +++ b/core/diyanet.py @@ -1,7 +1,6 @@ import pprint from datetime import datetime from typing import List -from urllib.parse import quote import httpx from aiocache import cached, Cache @@ -35,11 +34,16 @@ async def parse_prayer_times(url: str) -> List[PrayerTimes]: items = [] for row in soup.select('#tab-1 .vakit-table tbody tr'): - cell_texts = (c.text.strip() for c in row.select('td')) - headers = PrayerTimes.__fields__.keys() - parsed = dict(zip(headers, cell_texts)) - parsed['date'] = datetime.strptime(parsed['date'], '%d.%m.%Y') - items.append(PrayerTimes(**parsed)) + cells = [c.text.strip() for c in row.select('td')] + items.append(PrayerTimes( + date=datetime.strptime(cells[0], '%d.%m.%Y'), + fajr=cells[2], + sun=cells[3], + dhuhr=cells[4], + asr=cells[5], + maghrib=cells[6], + isha=cells[7], + )) return items diff --git a/requirements.txt b/requirements.txt index 32782af..804f3e0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ beautifulsoup4==4.10.0 fastapi==0.74.1 -httpx==0.22.0 +httpx==0.23.3 uvicorn==0.17.5 -aiocache==0.11.1 \ No newline at end of file +aiocache==0.11.1 +pydantic==1.10.7