blob: 13ccc0a53fc5df3088a50f06dee939f9145aa552 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import datetime
from bs4 import BeautifulSoup
datetime_time = datetime.date.today() + datetime.timedelta(days=1)
formatted_time = datetime_time.strftime("%Y-%m-%d")
yesterday_datetime_time = datetime.date.today()
yesterday_formatted_time = yesterday_datetime_time.strftime("%Y-%m-%d")
with open(yesterday_formatted_time + ".html") as file:
soup = BeautifulSoup(file, "html.parser")
today_trs = soup.find_all("tr", class_="today")
for tr in today_trs:
next_tr = tr.find_next("tr")
if next_tr:
try:
if next_tr["class"] == ["not-today"]:
next_tr["class"] = "today"
tr.decompose()
else:
tr.parent.parent.decompose()
except KeyError:
tr.parent.parent.decompose()
else:
tr.parent.parent.decompose()
with open(formatted_time + ".html", "w") as file:
file.write(str(soup))
|