33 lines
966 B
Python
33 lines
966 B
Python
from bs4 import BeautifulSoup
|
|
import requests
|
|
|
|
api_token = '1437509413:AAHyyA5tnDW4cJm2SAdj1655YAwbuGQVuNU'
|
|
#channel_name = '@kaktusdobijecka'
|
|
#devlog_channel_name = -1001399814968
|
|
#path = 'https://api.telegram.org/bot%s/sendMessage' % api_token
|
|
kaktus = 'https://www.mujkaktus.cz/novinky'
|
|
|
|
def last_text(text):
|
|
with open('last.txt', 'r+', encoding='utf-8') as f:
|
|
if f.read() == text:
|
|
return True
|
|
else:
|
|
f.seek(0)
|
|
f.truncate(0)
|
|
f.write(text)
|
|
return False
|
|
|
|
print('Updating last text...')
|
|
text = requests.get(kaktus).text
|
|
bs = BeautifulSoup(text, 'html.parser')
|
|
entries = bs.find_all("div", {"class": "journal-content-article"})
|
|
|
|
entry = entries[0]
|
|
split = entry.text.split('\n')
|
|
split = [_ for _ in split if _ and _ != 'Sdílet na Facebooku']
|
|
text = '\n\n'.join(split)
|
|
|
|
updated = not last_text(text)
|
|
print('Updated:', updated)
|
|
print('Last text:', text)
|