Booking a tennis court at ZHS München does not require online payment - payment is done in-person prior to playing. There are no no-show fees. Hence, the chance that people reserve a court and never show up is very high. However, what often happens is that people cancel the bookings.
An automatic crawler that checks if there are tennis courts available at a given date & time. If so, the court is automatically booked and a confirmation email is sent out.
- Clone the repository
- Install poetry.
pip install poetry
// Alternativelypip3 install poetry
- Navigate into the root directory
poetry install
- create a
.env
file in the root directory. See.env.template
- Run
python3 cli.py --help
to see the command line arguments
Running
python3 cli.py --date 2022-10-15 --time-window 16 18 --receiver-email leo@tennis.de --book-court true --interval 10
means that I - want to play on the 15th of October 2022 - between 4pm and 6pm (boundaries included) - if a court is found, it will be booked and the confirmation email will be sent to leo@tennis.de - the ZHS page will be checked every 10 seconds
The log output will like the following:
2022-10-14 18:31:25.978 | INFO | __main__:verify_date:52 - Date 2022-10-15 is valid
2022-10-14 18:31:25.979 | INFO | __main__:verify_start_end:23 - Time Window (16, 18) is valid
2022-10-14 18:31:25.979 | INFO | __main__:verify_email:74 - Email leo@tennis.de is valid
2022-10-14 18:31:25.980 | INFO | src.book_court:__init__:64 - BookTennisCourt successfully instantiated
2022-10-14 18:31:25.980 | INFO | src.zhs:__init__:61 - Zhs successfully instantiated
2022-10-14 18:31:25.980 | INFO | src.zhs:run_court_search:243 - Crawling page number 2...
2022-10-14 18:31:26.075 | INFO | src.zhs:run_court_search:243 - Crawling page number 3...
2022-10-14 18:31:26.176 | INFO | src.zhs:run_court_search:243 - Crawling page number 4...
2022-10-14 18:31:26.250 | INFO | src.zhs:run_court_search:251 - 0 relevant courts were found!
2022-10-14 18:31:26.251 | INFO | src.zhs:run_court_search:267 - No courts found. Zhs will be crawled again in 10 seconds ...
2022-10-14 18:31:36.255 | INFO | src.zhs:run_court_search:243 - Crawling page number 2...
2022-10-14 18:31:36.498 | INFO | src.zhs:run_court_search:243 - Crawling page number 3...
2022-10-14 18:31:36.799 | INFO | src.zhs:run_court_search:243 - Crawling page number 4...
2022-10-14 18:31:37.013 | INFO | src.zhs:run_court_search:251 - 0 relevant courts were found!
2022-10-14 18:31:37.013 | INFO | src.zhs:run_court_search:267 - No courts found. Zhs will be crawled again in 10 seconds ...
- When the courts re-open in spring 2023, the HTML code of the website must be analysed to make the script work again as some tags have changed and caused the script to break
- clean-up & refactoring, e.g. split up functions; add more comments; underscore private methods & variables
- Put proper headers to requests.get
- switch to requests.Session -> class variable
- update python version
- build a front-end
- telegram / discord bot
ZHS München: (https://ssl.forumedia.eu/zhs-courtbuchung.de/reservations.php?action=showRevervations&type_id=1&page=2)