Answer the question
In order to leave comments, you need to log in
How to make a check for new news so that the program understands that there is new news and immediately parses it?
I made a telegram bot that parses football matches and wanted to add news about football. you need to do so when a new news appears on the site, you should parse it to all users of the bot!
Answer the question
In order to leave comments, you need to log in
Option 1. The site is yours: create an event and pull it in the bot when adding news
Option 2. The site is not yours (which is most likely): use crone/ schedule , get the news and check, if there are new ones, then parse them and send them to all users, for example (consider - pseudocode):
import schedule
import time
my_news = [] #массив новостей/любая другая структура/или что-то с БД
def job():
#запрос за новостями
def check_new():
#проверяем, есть ли тут новые новости, если есть, то отправляем юзерам
schedule.every(10).minutes.do(job) #отправлять запрос каждые 10 минут
schedule.every(15).minutes.do(check_new)
while 1:
schedule.run_pending()
time.sleep(1)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question