Git Product home page Git Product logo

asvz_bot's Introduction

ASVZ Bot - Automatic Enrollment Script

This is a simple ASVZ (Akademischer Sportverband Zürich) enrollment script for people who always miss the enrollment period of classes as cycling, rowing, etc. It is based on Python with Selenium.

Full instructions to set it up for automatic weekly enrollment are given below.

This is an adapted version from @jstiefel and @bartonp2.

Features

  • Tested for ETH and ZHAW
  • When lesson not found on first page, load more and search again.
  • Sends Telegram message with lesson information.
  • Templates for config.ini and credentials.ini
  • simplified installation

  • It works with any enrollment time difference
  • will keep retrying if lesson is already booked out in case place becomes available
  • uses config files for easily enrolling for different lessons
  • It also doesn't require to install the geckodriver

Installation

These instructions are for Ubuntu. It was tested on Ubuntu 18.04, Python 3.7.4 and Firefox 81.0

Clone this repository:

cd
git clone https://github.com/bartonp2/asvz_bot.git

Set up new virtual environment with venv:

sudo pip install venv
python3 -m venv ~/asvz_bot_python
source asvz_bot_python/bin/activate

Install Selenium and Firefox webdriver:

pip install --upgrade pip
pip install -r REQUIREMENTS.txt
deactivate

Run

Enter your login credentials in the credentials.ini file. These will be reused for all your registrations

For each lesson you want to register create a config file like the 'config.ini' example. Link to the corresponding "Sportfahrplan", day, time and facility. Your data is safe since it just uses your own webbrowser. But only use it on your private device since credentials are saved in this file as plain text.

There are two methods to use this script:

  1. Run it manually on the day of enrollment
  2. Run one or several as cron job on your device (e.g. Laptop, Raspberry Pi, ...) for automatic weekly enrollment

1. Run it manually

Run script once for single enrollment at defined time on the day before enrollment start. Don't close the terminal.

cd 
source asvz_bot_python/bin/activate
cd asvz_bot
python asvz_bot.py config.ini

2. Create a cron job

Copy asvz_bot.py for each enrollment you want to make in one week. Then define a cron job for each of these with corresponding time.

crontab -e

To run enrollment for example at 21:30 each Tuesday, enter:

30 21 * * 2 python asvz_bot.py config.ini
# Shell variable for cron
SHELL=/bin/bash
# PATH variable for cron
PATH=/usr/local/bin:/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/bin/X11
# 
# m h  dom mon dow   command
30 21 * * 3 /home/<user>/asvz_bot_python/bin/python /home/<user>/asvz_bot/asvz_bot.py > /home/<user>/asvz_bot/asvz.log 2>&1

Telegram Notifications

To receive telegram notifications when the enrollment worked or an error occurred:

  1. Create a telegram bot with the botfather
  2. Run telegram-send --configure and paste in the token from your telegram bot
  3. Use the -t option when running asvz.py

asvz_bot's People

Contributors

bartonp2 avatar jstiefel avatar lthiet avatar matteodelucchi avatar tetterl 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.