Бот не проходит защиту Cloudflare
Хочу сделать бота для записи в визовый центр, нашел проект на GitHub , но залогиниться не получается, бот не может пройти cloudflare, как я понял.
import time
import threading
import undetected_chromedriver as uc
from utils import *
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from telegram.ext import Updater
from telegram.ext import CommandHandler
from configparser import ConfigParser
class VFSBot:
def __init__(self):
config = ConfigParser()
config.read('config.ini')
self.url = config.get('VFS', 'url')
self.email_str = config.get('VFS', 'email')
self.pwd_str = config.get('VFS', 'password')
self.interval = config.getint('DEFAULT', 'interval')
self.channel_id = config.get('TELEGRAM', 'channel_id')
token = config.get('TELEGRAM', 'auth_token')
admin_ids = list(map(int, config.get('TELEGRAM', 'admin_ids').split(" ")))
updater = Updater(token, use_context=True)
dp = updater.dispatcher
dp.add_handler(AdminHandler(admin_ids))
dp.add_handler(CommandHandler("start", self.start))
dp.add_handler(CommandHandler("help", self.help))
dp.add_handler(CommandHandler("quit", self.quit))
updater.start_polling()
updater.idle()
def login(self, update, context):
self.browser.get((self.url))
if "You are now in line." in self.browser.page_source:
update.message.reply_text("You are now in queue.")
WebDriverWait(self.browser, 20).until(EC.presence_of_element_located((By.NAME, 'username')))
time.sleep(1)
self.browser.find_element(by=By.NAME, value='username').send_keys(self.email_str)
self.browser.find_element(by=By.NAME, value='password').send_keys(self.pwd_str)
#update.message.reply_text("Sending Captcha...")
captcha_img = self.browser.find_element(by=By.ID, value='content')
self.captcha_filename = 'captcha.png'
with open(self.captcha_filename, 'wb') as file:
file.write(captcha_img.screenshot_as_png)
captcha = break_captcha()
self.browser.find_element(by=By.NAME, value='CaptchaInputText').send_keys(captcha)
time.sleep(1)
self.browser.find_element(by=By.ID, value='btnSubmit').click()
if "Reschedule Appointment" in self.browser.page_source:
update.message.reply_text("Successfully logged in!")
while True:
try:
self.check_appointment(update, context)
except WebError:
update.message.reply_text("An WebError has occured.\nTrying again.")
raise WebError
except Offline:
update.message.reply_text("Downloaded offline version. \nTrying again.")
continue
except Exception as e:
update.message.reply_text("An error has occured: " + e + "\nTrying again.")
raise WebError
time.sleep(self.interval)
elif "Your account has been locked, please login after 2 minutes." in self.browser.page_source:
update.message.reply_text("Account locked.\nPlease wait 2 minutes.")
time.sleep(120)
return
elif "The verification words are incorrect." in self.browser.page_source:
#update.message.reply_text("Incorrect captcha. \nTrying again.")
return
elif "You are being rate limited" in self.browser.page_source:
update.message.reply_text("Rate Limited. \nPlease wait 5 minutes.")
time.sleep(300)
return
else:
update.message.reply_text("An unknown error has occured. \nTrying again.")
#self.browser.find_element(by=By.XPATH, value='//*[@id="logoutForm"]/a').click()
raise WebError
это часть кода, которая этим занимается, возможно кто-то может мне помочь, т.к до этого я с подобной задачей не сталкивался.