-
@uurtpcu Looks like you're using a newer version of Selenium and that is causing some issues. Here's a thread with possible solutions for this error: https://stackoverflow.com/questions/72754651/attributeerror-webdriver-object-has-no-attribute-find-element-by-xpath
-
@uurtpcu Glad to hear that it works for you! There were no booking fees when I tested the script. So in theory the bot could book an appointment automatically. But the success rate was not 100%. I mentioned it in the comments:
Note: the piece where the bot actually books the slot is rather unreliable since the website often lags and reloads pages randomly during the booking process. The bot will try its best, but if you see a free slot alert it's better to try and book it yourself.
-
Hi, Mikhail Malikov i was wondering if this work on this website : https://algeria.blsspainvisa.com/
also the bot seems to open chrome and it stuck at cloudflare clearance and auto close weird
-
HI GUYS WHEN I ACCESS TO THE WEB SITE OF BLS ALGERIA ON chrome profile IS CUT AUTOMATIQUE AND REPLY THAT AGAIN AND REPLEY THAT AGAIN AND SHOW THIS :"UserWarning: using ChromeOptions.user_data_dir might stop working in future versions.use uc.Chrome(user_data_dir='/xyz/some/data') in case you need existing profile folder warnings.warn(
-
""" This is a script designed to book appointments in a BLS visa center. Usage guide: 1. Install selenium and undetected_chromedriver python packages using pip. 2. Install selenium application. 3. Register at 2captcha.com, make a payment (2$ minimum should be enugh) and insert an API key into the CAPTCHA_API_KEY variable. 4. Setup telegram notifications 4a. Create a new bot or use any existing one. Insert its key into the BOT_TOKEN variable 4b. Create two new group chats. One will be used for status and debug messages, another for error messages and new slots notifications. 4c. Copy chat IDs into the DEFAULT_CHAT_ID and ALERT_CHAT_ID variables. 4d. Add the bot to both groups so it can write here. 5. Insert your email and password from BLS website to EMAIL and PASSWORD variables. You can also change the JURISDICTION_ID, CENTER_ID and CATEGORY to your preference.
Note: the piece where the bot actually books the slot is rather unreliable since the website often lags and reloads pages randomly during the booking process. The bot will try its best, but if you see a free slot alert it's better to try and book it yourself.
""" import undetected_chromedriver as uc from time import sleep from random import random import requests from selenium.webdriver.support.ui import Select from selenium.webdriver.common.keys import Keys
EMAIL = "" PASSWORD = "" JURISDICTION_ID = "Scotland" CENTER_ID = "Edinburgh" CATEGORY = "Normal"
CAPTCHA_API_KEY = "" BOT_TOKEN = "" DEFAULT_CHAT_ID = "" ALERT_CHAT_ID = ""
def send_message(text, urgency="default"): if urgency == "alert": chat_id = ALERT_CHAT_ID else: chat_id = DEFAULT_CHAT_ID requests.get( "https://api.telegram.org/bot{}/sendMessage".format(BOT_TOKEN), params={"text": text, "chat_id": chat_id} )
def solve_captcha(driver): sleep(3) url = driver.current_url sitekey = driver.find_element_by_class_name("h-captcha").get_attribute("data-sitekey") send_message("solving captcha at " + url) resp = requests.get( "http://2captcha.com/in.php", params={ "method": "hcaptcha", "key": CAPTCHA_API_KEY, "sitekey": sitekey, "pageurl": driver.current_url, }) resp.raise_for_status() if resp.text[:2] == "OK": request_id = resp.text[3:] else: raise ValueError("bat response from 2captcha: " + resp.text) sleep(30) for _ in range(10): resp = requests.get( "http://2captcha.com/res.php", params={ "key": CAPTCHA_API_KEY, "action": "get", "id": request_id, }) resp.raise_for_status() if resp.text == "CAPCHA_NOT_READY": sleep(5) continue elif resp.text.startswith("ERROR_"): raise ValueError("bat response from 2captcha: " + resp.text) else: text = resp.text[3:] element = driver.find_element_by_name("h-captcha-response") driver.execute_script("arguments[0].innerText = '{}'".format(text), element) element = driver.find_element_by_name("g-recaptcha-response") driver.execute_script("arguments[0].innerText = '{}'".format(text), element) sleep(1) return raise ValueError("captcha timeout")
def login(driver): sleep(5) driver.find_element_by_xpath("//a[contains(@HRef,'login')]").click() sleep(5) driver.find_element_by_name("email").send_keys(EMAIL) driver.find_element_by_name("password").send_keys(PASSWORD) solve_captcha(driver) driver.find_element_by_class_name("btn-success").click() sleep(3) driver.find_element_by_class_name("glyphicon-calendar").click() sleep(3) Select(driver.find_element_by_id('JurisdictionId')).select_by_visible_text(JURISDICTION_ID) sleep(0.8) Select(driver.find_element_by_id('centerId')).select_by_visible_text(CENTER_ID) sleep(0.8) Select(driver.find_element_by_id('category')).select_by_visible_text(CATEGORY) sleep(0.8) solve_captcha(driver) driver.find_element_by_class_name("btn-success").click()
while True: try: options = uc.ChromeOptions() options.user_data_dir = "~/chrome_profile" driver = uc.Chrome(options=options, version=94) driver.get("https://uk.blsspainvisa.com/visa4spain/book-date/YKSqqJqhhQ") login(driver) for i in range(10000): source_code = driver.page_source dates_start = source_code.find("available_dates") dates_end = source_code.find("fullCapicity_dates") if dates_start == -1 or dates_end == -1: break dates = source_code[dates_start+19:dates_end-9] if dates: send_message("dates available " + dates, urgency="alert") dates = dates[1:] dates = dates[:-1] dates = dates.split('", "') for i in dates: if int(i[:2]) >= 10 or int(i[3:5]) > 4: date = i break else: send_message("not booking (too early)", urgency="alert") continue send_message("trying to book " + date, urgency="alert") Select(driver.find_element_by_id("VisaTypeId")).select_by_visible_text("Business") sleep(0.1) element = driver.find_element_by_id("app_date") driver.execute_script("arguments[0].innerText = '{}'".format(date), element) driver.find_element_by_id("app_date").send_keys(Keys.ENTER) sleep(20) Select(driver.find_element_by_id("app_time")).select_by_index(1) driver.find_element_by_id("app_date").send_keys(date) sleep(5) solve_captcha(driver) driver.find_element_by_class_name("btn-success").click() sleep(3) send_message("booked successfully?", urgency="alert") send_message("refreshing page") driver.refresh() sleep(30) except BaseException as e: send_message(str(e), urgency="alert") finally: driver.close() sleep(30)
-
Hello @Sofiane Hassaine @yasmina480900 Cane you give me your contact please email or telegram
Please register or sign in to comment