fix portenf_sa_gov_au

failed when month div above calendar would show only one month (July 2024) instead of a month range like: July - May 2024
This commit is contained in:
5ila5
2024-07-05 12:07:31 +02:00
committed by 5ila5
parent cdde7bb2fc
commit fe4cb7b010

View File

@@ -155,9 +155,14 @@ class Source:
soup = BeautifulSoup(r.text, "html.parser") soup = BeautifulSoup(r.text, "html.parser")
cal_header = soup.find("th", {"class": "header-month"}).find("span").text cal_header = soup.find("th", {"class": "header-month"}).find("span").text
from_month = cal_header.split("-")[0].strip() month_range = cal_header.split("-")
to_month = cal_header.split("-")[1].strip().split(" ")[0] from_month = month_range[0].strip()
to_year = from_year = cal_header.split("-")[1].strip().split(" ")[1]
to_month, to_year, from_year = None, None, None
if len(month_range) > 1:
to_month = month_range[1].strip().split(" ")[0]
to_year = from_year = month_range[1].strip().split(" ")[1]
# if main month contains a year, set it (maybe happens in december???) # if main month contains a year, set it (maybe happens in december???)
if len(from_month.split(" ")) > 1: if len(from_month.split(" ")) > 1:
from_year = from_month.split(" ")[1] from_year = from_month.split(" ")[1]