mirror of
https://github.com/serega404/VodokanalBot.git
synced 2025-07-15 06:12:20 +03:00
Compare commits
3 Commits
80af7ec775
...
main
Author | SHA1 | Date | |
---|---|---|---|
edb51bb696
|
|||
758c090824
|
|||
132a9d81ee
|
12
main.py
12
main.py
@ -41,7 +41,7 @@ for tag in soup.find_all('font', size='2', face='VERDANA'):
|
||||
date = tag.select_one('font:nth-of-type(1)').b.text
|
||||
if not(date.split('.')[0] == str(datetime.today().day).zfill(2) and date.split('.')[1] == str(datetime.today().month).zfill(2)):
|
||||
continue
|
||||
elements.append(tag.select_one('font:nth-of-type(2)').text.replace('\n', ''))
|
||||
elements.append(date + "$" + tag.select_one('font:nth-of-type(2)').text.replace('\n', ''))
|
||||
|
||||
if elements == []:
|
||||
print("No posts")
|
||||
@ -62,12 +62,16 @@ def send_message(message):
|
||||
# Compare db and elements
|
||||
|
||||
if db is not None:
|
||||
diff = list(set(elements).symmetric_difference(set(db)))
|
||||
diff = set(elements) - set(db)
|
||||
if diff == []:
|
||||
print("No new posts")
|
||||
exit()
|
||||
|
||||
for i in diff:
|
||||
send_message(i)
|
||||
send_message(i.split("$",1)[1])
|
||||
else:
|
||||
for element in elements:
|
||||
send_message(element)
|
||||
send_message(element.split("$",1)[1])
|
||||
|
||||
# Save database
|
||||
|
||||
|
Reference in New Issue
Block a user