instantviw
import schedule
import time
import telebot
import requests
from bs4 import BeautifulSoup
from mongoengine import connect, Document, StringField
token = 'token'
bot = telebot.TeleBot(token)
connect('telegram_url')
class Telegram(Document):
url = StringField()
author = StringField()
def job():
r = requests.get('https://instantview.telegram.org/contest')
soup = BeautifulSoup(r.text, "html.parser")
item = soup.findAll("div", {"class": "list-group-contest-item"})
l = [i.url for i in Telegram.objects]
for i in item[1:]:
domain = i.find("div", {"class": "contest-item-domain"})
author = i.find("span", {"class": "contest-item-cell contest-item-candidate"})
try:
author = author.findAll("a")[1].text
except IndexError:
author = None
if domain.a.text not in l:
Telegram(url=domain.a.text, author=author).save()
bot.send_message('user_id', domain.a.text)
schedule.every(10).minutes.do(job)
while True:
schedule.run_pending()
time.sleep(60)