from aiogram import Bot,types
from aiogram.dispatcher import Dispatcher
from aiogram.utils import executor
import selenium
import selenium.webdriver.support.ui as ui
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
import requests
import random
from bs4 import BeautifulSoup as bs
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.dispatcher import FSMContext
from aiogram.dispatcher.filters.state import State, StatesGroup
from multiprocessing import Pool
storage = MemoryStorage()
def get_free_proxies():
url = "https://sslproxies.org./"
# получаем ответ HTTP и создаем объект soup
soup = bs(requests.get(url).content, "html.parser")
proxies = []
for row in soup.find("table", attrs={"class": "table table-striped table-bordered"}).find_all("tr")[1:]:
tds = row.find_all("td")
try:
ip = tds[0].text.strip()
port = tds[1].text.strip()
host = f"{ip}:{port}"
proxies.append(host)
except IndexError:
continue
return proxies
#command of watching video
def watch_video(PROXY):
#login
opts = WebDriver.ChromeOptions()
opts.add_argument('--proxy-server=%s' % PROXY)
opts.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36")
driver = webdriver.Chrome(chrome_options=opts, executable_path=r'C:\Users\s-isroilov\Desktop\chromedriver.exe')
driver.get('https://accounts.google.com/v3/signin/identifier?dsh=S486906257%3A1665674407916812&continue=https%3A%2F%2Faccounts.google.com%2F&followup=https%3A%2F%2Faccounts.google.com%2F&passive=1209600&flowName=GlifWebSignIn&flowEntry=ServiceLogin&ifkv=AQDHYWrVJuo3NB8buJ3kQD6yKMDsBX37LSgvbiX3TAtAp2-jAMW566ou8IdcVh2MqgcjG9sQpAglOA')
c = 0
while c != 10:
driver.implicitly_wait(1000)
email = driver.find_element_by_id('identifierId')
email.send_keys('gmail')
nextBtn = driver.find_element_by_id('identifierNext')
nextBtn.click()
driver.implicitly_wait(5)
try:
driver.find_element_by_name("Passwd").send_keys("psd")
driver.find_element_by_id("passwordNext").click()#clicking next
c = 10
except:
element = driver.find_element_by_id('next')
element.click()
continue
#_______
#timer
driver.get(link)
#subscribing
driver.implicitly_wait(1000)
sub = driver.find_element_by_id('subscribe-button').click()
driver.implicitly_wait(10000)
if driver.find_element_by_id('cancel-button')!=None:
driver.find_element_by_id('cancel-button').click()
while True:
driver.implicitly_wait(1000000)
if driver.find_element_by_class_name('ytp-autonav-endscreen-upnext-thumbnail') !=None:
return 1
else:
continue
bot = Bot('TOKEN')
dp = Dispatcher(bot, storage=storage)
class UserState(StatesGroup):
times = State()
link = State()
#telegram bot
@dp.message_handler(commands = ['start', 'help'])
async def start(message : types.Message):
await message.reply('Use command /watch')
@dp.message_handler(commands = ['watch'])
async def new_message(message: types.Message):
await message.reply('Enter the link to the video')
await UserState.link.set()
@dp.message_handler(state=UserState.link)
async def ok(message: types.Message, state:FSMContext):
await state.update_data(link=message.text)
await message.reply('Now enter how many times shall I watch this video?(just a number)')
await UserState.times.set()
def finish():
bot.reply('Successfully watched')
@dp.message_handler(state=UserState.times)
async def nevermind(message:types.Message, state:FSMContext):
await state.update_data(times=int(message.text))
data = await state.get_data()
if data['times']>100:
await message.reply('Please enter number that is less than 100 (now write /watch again)!!!')
global link
link = data['link']
times = data['times']
global proxies
proxies = get_free_proxies()
p = Pool(times)
for PROXY in proxies:
p.map(watch_video, PROXY)
executor.start_polling(dp, skip_updates=True)