написал код который должен использовать пул и запускать несколько функций сразу:
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 time
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
storage = MemoryStorage()
def get_free_proxies():
url = "https://multiproxy.org/txt_all/proxy.txt"
# получаем ответ HTTP и создаем объект soup
global proxies
proxies = bs(requests.get(url).content, "html.parser")
proxies = str(proxies)
proxies = proxies.split(' ')
proxies = str(proxies)
proxies = proxies.split(f'\\n')
return proxies
#command of watching video
def watch_video(c):
#login
opts = Options()
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")
proxies = get_free_proxies()
opts.add_argument('--proxy-server=%s' % proxies[c])
driver = webdriver.Chrome(chrome_options=opts, executable_path=r'C:\Users\s-isroilov\Desktop\chromedriver.exe')
driver.get('https://accounts.google.com/signup/v2/webcreateaccount?biz=false&cc=UZ&continue=https%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3Dzaregatsya%26oq%3Dzaregatsya%26aqs%3Dchrome..69i57.2411j0j1%26sourceid%3Dchrome%26ie%3DUTF-8&dsh=S2080565863%3A1665468718327866&flowEntry=SignUp&flowName=GlifWebSignIn&hl=ru&ifkv=AQDHYWqdgbDaL-9wueIt0CeC5_kNMk4ufHCDs3oVXbzjDofs2pskEKXgR_t-iOrPzD11RFgI5nDVzw')
c = 0
while c != 10:
driver.implicitly_wait(10)
email = sdriver.find_element_by_id('identifierId')
email.send_keys('gmail')
nextBtn = sdriver.find_element_by_id('identifierNext')
nextBtn.click()
driver.implicitly_wait(5)
try:
driver.find_element_by_name("Passwd").send_keys("password")
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({data['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()
@dp.message_handler(text=int(), state=UserState.times)
async def nevermind(message:types.Message, state:FSMContext):
await state.update_data(times=int(message.text))
data = await state.get_data()
p = Pool({data['times']})
p.map(watch_video, list(range(0,len(proxies))))
executor.start_polling(dp, skip_updates=True)
ну и ошибка в том что походу переменную взятую с тг он прям никак не хочет считать инт или
ковертировать , объясните как тогда исп переменную?(вот собственно ошибка) :
Updates were skipped successfully.
Task exception was never retrieved
future: <Task finished name='Task-18' coro=<Dispatcher._process_polling_updates() done, defined at C:\Users\s-isroilov\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\dispatcher.py:407> exception=TypeError("'int' object is not iterable")>
Traceback (most recent call last):
File "C:\Users\s-isroilov\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 415, in _process_polling_updates
for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
File "C:\Users\s-isroilov\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 235, in process_updates
return await asyncio.gather(*tasks)
File "C:\Users\s-isroilov\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\handler.py", line 116, in notify
response = await handler_obj.handler(*args, **partial_data)
File "C:\Users\s-isroilov\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 256, in process_update
return await self.message_handlers.notify(update.message)
File "C:\Users\s-isroilov\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\handler.py", line 107, in notify
data.update(await check_filters(handler_obj.filters, args))
File "C:\Users\s-isroilov\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\filters\filters.py", line 72, in check_filters
f = await execute_filter(filter_, args)
File "C:\Users\s-isroilov\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\filters\filters.py", line 56, in execute_filter
return await filter_.filter(*args, **filter_.kwargs)
File "C:\Users\s-isroilov\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\filters\filters.py", line 161, in __call__
return await self.check(*args)
File "C:\Users\s-isroilov\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\filters\builtin.py", line 331, in check
equals = list(map(_pre_process_func, self.equals))
TypeError: 'int' object is not iterable