Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import telebot
- import time
- import logging
- from bs4 import BeautifulSoup
- import requests
- from data import TOKEN, list
- logging.basicConfig(filename="logfile.py", level=logging.INFO)
- bot = telebot.TeleBot(TOKEN)
- class Kanal:
- name: str = list[0]
- stpage: int = list[1]
- embaded: str = "?embed=1"
- def solver(link):
- try:
- bot.send_message(chat_id=-1001230182875, text=link)
- logging.info('No problem detected')
- except OSError:
- logging.info("ConnectionError - Sending again after 5 seconds!!!")
- time.sleep(5)
- bot.send_message(chat_id=-1001230182875, text=link)
- logging.info('Problem solved')
- def collector():
- logging.info("Collector started")
- counter = 0
- counter2 = 1
- Kanal.name = list[counter]
- Kanal.stpage = list[counter2]
- while True:
- clear = lambda: os.system('cls')
- clear()
- print()
- print(" /> フ")
- print(" | 0 0 |")
- print(" /`ミ _x 彡")
- print(" / |")
- print(" / ヽ ノ")
- print(" / ̄| | | |")
- print(" | ( ̄ヽ__ヽ_)_)")
- print(" \二つ")
- print("Проверяем канал ", Kanal.name)
- time.sleep(2)
- clear = lambda: os.system('cls')
- clear()
- print()
- print(" |> フ ")
- print(" | 0 0 |")
- print(" /ミ x_ 彡")
- print(" / |")
- print(" / ヽ ノ")
- print(" / ̄| | | |")
- print(" | ( ̄ヽ__ヽ_)_)")
- print(" \二つ")
- print("Проверяем канал ", Kanal.name)
- time.sleep(2)
- r = requests.get(Kanal.name + str(Kanal.stpage) + Kanal.embaded)
- data = r.text
- soup = BeautifulSoup(data, 'lxml')
- pg_not_fnd = soup.find_all("div", {"class": "tgme_widget_message_error"})
- if len(pg_not_fnd) > 0:
- counter = counter + 2
- counter2 = counter2 + 2
- stop = len(list)
- if counter >= stop:
- logging.info("Sleeping")
- for i in reversed(range(1, 500)):
- time.sleep(1)
- clear = lambda: os.system('cls')
- clear()
- print()
- print(" /> フ")
- print(" | _ _|")
- print(" /`ミ _x 彡")
- print(" / |")
- print(" / ヽ ノ")
- print(" / ̄| | | |")
- print(" | ( ̄ヽ__ヽ_)_)")
- print(" \二つ")
- print()
- sys.stderr.write(f"{i:2d}\r")
- time.sleep(1)
- time.sleep(1)
- clear = lambda: os.system('cls')
- clear()
- print()
- print(" /> フ")
- print(" | _ _|")
- print(" /`彡 _Х ミ")
- print(" / |")
- print(" / ヽ ノ")
- print(" / ̄| | | |")
- print(" | ( ̄ヽ__ヽ_)_)")
- print(" \二つ")
- print()
- sys.stderr.write(f"{i:2d}\r")
- time.sleep(1)
- break
- Kanal.name = list[counter]
- Kanal.stpage = list[counter2]
- else:
- for results in soup.find_all("a", {"class": "tgme_widget_message_date"}):
- link = results.get('href')
- list[counter2] = int(list[counter2]) + 1
- solver(link)
- output = open("data.py", 'w')
- print("TOKEN = '11*************************************************'", file=output)
- print("list =", list, file=output)
- output.close()
- Kanal.stpage = str(int(Kanal.stpage) + 1)
- while True:
- logging.info("Reboot True")
- collector()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement