├── README.md └── parser.py /README.md: -------------------------------------------------------------------------------- 1 | # python_parser 2 | this repo for parser 3 | -------------------------------------------------------------------------------- /parser.py: -------------------------------------------------------------------------------- 1 | from bs4 import BeautifulSoup 2 | import telebot 3 | import requests 4 | import schedule 5 | import random 6 | import time 7 | 8 | #Create a sender BOT 9 | TOKEN = 'your token' 10 | bot = telebot.TeleBot(TOKEN) 11 | group_id = 'your telegram id' 12 | #Parser body 13 | url = 'http://tafsir.ru' 14 | page = requests.get(url) 15 | 16 | soup = BeautifulSoup(page.text, "html.parser") 17 | titles = soup.findAll('p') 18 | 19 | hadis = [] 20 | for x in titles: 21 | hadis.append(x.text.strip()) 22 | 23 | random_hadis = hadis.reverse() 24 | 25 | res = random.choice(random_hadis) 26 | 27 | def get_hadis_today(): 28 | bot.send_message(group_id, f' Bugunlik matn : \n << {res} >>') 29 | 30 | schedule.every().day.at('08:15').do(get_hadis_today) 31 | 32 | while True: 33 | schedule.run_pending() 34 | time.sleep(1) 35 | --------------------------------------------------------------------------------