Skip to content

uzairkabeer1/Automated-italy-Appointment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BLS Appointment Booking Automation Script


🚨 Important Note: Captcha Handling 🚨

Please be aware of the following regarding captcha handling:

  • Captcha v2: The login captcha might take a significant amount of time to complete, as it is v2.
  • Text Captcha: This typically processes in no time.

If you encounter a captcha type that differs from what is described (for example, if text captcha appears instead of v2), you might need to adjust the captcha handling in your code:

  1. Swapping Captcha Handling: If there is a shift in captcha type, swap the lines of code relevant to captcha handling as necessary.
  2. Captcha v2 Site-Key: If you need to handle captcha v2 specifically, ensure you include the captcha v2 site-key. You can find this site-key by inspecting the element on the captcha page.

Make sure to update your implementation based on the current captcha type to ensure smooth functionality.


Overview

This Python script automates the process of logging into the BLS Italy Pakistan appointment system, checking for available appointments, and attempting to book one using the Playwright browser automation tool. The script is integrated with 2Captcha to solve both image-based CAPTCHAs and reCAPTCHA v2 challenges. It periodically refreshes the page to check for new appointment availability and tries to book an appointment when it becomes available.

Features

  • Login Automation: Automatically logs into the BLS Italy Pakistan website using the provided credentials.
  • CAPTCHA Solving: Utilizes the 2Captcha API to solve both image-based CAPTCHAs and reCAPTCHA v2 challenges.
  • Appointment Availability Check: Continuously monitors for available appointments for a specified date.
  • Form Auto-fill: Automatically fills in required fields for appointment booking (location, appointment type, etc.).
  • Error Handling and Retry: Handles timeouts, login issues, and pop-up windows with retries to maintain stability.
  • Session Management: Automatically logs back in if the session expires or if the user is logged out.

Prerequisites

  1. Python: Ensure Python 3.x is installed.
  2. Playwright: Install Playwright and set it up by running the following commands:
    pip install playwright
    playwright install
  3. Pillow: Used for image handling in CAPTCHAs. Install it with:
    pip install pillow
  4. Requests: Used for sending HTTP requests (to 2Captcha and for image downloads). Install with:
    pip install requests

How to Set Up

  1. 2Captcha API Key: Obtain a 2Captcha API key from 2Captcha and insert it into the script by replacing '<************>' in the API_KEY variable.

  2. BLS Account Credentials: Update the placeholders <EMAIL> and <PASSWORD> in the login function with your BLS login credentials.

  3. Python Libraries: Ensure all required libraries are installed:

    • Playwright
    • Pillow
    • Requests
  4. Playwright Setup: Run the following to install the necessary browser binaries:

    playwright install

How to Run

  1. Ensure all dependencies are installed.
  2. Run the script from the terminal:
    python play2.py

Key Functions

  • solve_recaptcha_v2(): Uses 2Captcha to solve the reCAPTCHA v2 challenge and returns the solution to be used in the login process.
  • solve_captcha(): Downloads the CAPTCHA image, sends it to 2Captcha, and returns the solution.
  • login(): Automates the login process using the provided credentials and solved reCAPTCHA.
  • check_appointment_date(): Checks if appointments are available for a specified date (11 September in this case).
  • main(): The main control loop for logging in, navigating to the appointment page, checking appointment availability, and booking.

Usage Notes

  • The script checks if an appointment is available for 11 September. If you wish to change the date, modify the check_appointment_date() function accordingly.
  • Ensure the BLS account credentials and 2Captcha API key are correct and up-to-date in the script.
  • The script runs in an infinite loop, checking for available appointments and refreshing the page regularly. To stop it, terminate the process manually.

Disclaimer

This script is intended for educational purposes. Automating appointment booking may violate terms of service for certain websites. Use this script responsibly and at your own risk.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages