Giter VIP home page Giter VIP logo

autopark's Introduction

AutoPark: Automated Weekday Parking Space Reservation System Using Python and Selenium

Python program to automate booking parking spaces in a web application for a parking garage on weekdays. This Python script uses Selenium to open the browser, log into the web application, and retrieve the necessary tokens from the localstore. Once the token is obtained, it will be used to send requests to the server and reserve a parking space in the private garage. Once reserved, it will send the details of the booked space via Telegram.

Requirements

  • Python 3.x
  • Selenium WebDriver
  • A WebDriver-compatible browser (Firefox, Chrome.)

Installation

  1. Install Python from python.org.

  2. Create a virtual enviroment

    python -m venv venv
  3. Activate the virtual enviroment

    On Windows System:

    source venv/Scripts/activate

    On Linux System:

    source venv/bin/activate
  4. Install libraries using pip:

    pip install -r requirements.txt

    or if you are using Python 3, you may have to use pip3

    pip3 install -r requirements.txt
  5. Download WebDriver
    You will also need a WebDriver for interfacing with different web browsers.

Important Note

  • Make sure to download the WebDriver version that corresponds to the version of the browser you are using. Otherwise, you might encounter compatibility issues.

Configuration

  1. Make sure to set up the .env file with the necessary environment variables:

    USERNAME_HIBO="your_username"
    PASSWORD_HIBO="your_password"
    TELEGRAM_TOKEN="your_telegram_bot_token"
    CHAT_ID="your_telegram_chat_id"
    LINK="web_link"
    URL="api_link"
  2. Import the environment variables into your script:

    from dotenv import load_dotenv
    load_dotenv()

Setting Up Telegram

  1. Create one by talking to @BotFather on Telegram.
  2. Obtain the bot's token, which BotFather will provide upon the creation of the bot.
  3. Start a conversation on your created bot's link
    https://t.me/<Your Bot's Name>
  4. To obtain your chat_id if you don't know it, search in your APP for a user named @userinfobot and type /start, then send a message to this bot. The ID will be displayed.

In these links, you will find manuals and examples for configuring the Telegram API:

Usage

  1. Run the script:

    python main.py
  2. The script will open the browser, perform the login, and fetch the requested data from the localStorage.

Compile

  1. Install cx-Freeze

    pip install cx-Freeze
  2. The script setup.py include geckodriver.exe, chromedriver.exe and .env file on the root

  3. To create a executable file run the next command.

    • On Windows System:
    python setup.py bdist_msi
    • On Linux System:
    python setup.py build

Code Explanation

  • The script uses Selenium to open up the browser and navigate to the specified URL.
  • It fills in form fields using identifiers from the HTML elements.
  • It runs a JavaScript script to pull data from localStorage.
  • Extracts and displays specific keys from the JSON object stored in localStorage.
  • Use this data to obtain the token and make a request to the server
  • After receiving the response, make another web request to send a message via Telegram.

Important Notes

  • The script handles exceptions for each action, outputting messages to the console if anything fails.
  • The localStorage data is printed as JSON objects for easier future use.
  • This script is designed to function when there are more than three items in the localStorage.
  • Before running the script, ensure you know which keys are stored in localStorage and their position. The script will extract values based on their position.

autopark's People

Contributors

davidcastagnetoa avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.