A small piece of code to scrape assignments of lecture Programmierparadigmen and send the updates through Telegram Bot. (Set variable chat_id
to send message to your account/ others account/a channel).
The reasons for this piece of code are:
- Instead of using official learning platform Ilias, all the assignments of this lecture are updated on this website.
- I'm too lazy to refresh the page and check if there's new assignments there.
- It's fun xD
- scrape the lecture page and get the html content.
- find the assignment table and get all assignment URLs.
- compare with the result of last scrape (saved as a local file), if new assignment material found, update the local file and send the updates to me through Telegram Bot.
- Python3
- Library dependencies:
import bs4, requests, os
import urllib.parse as ul
- A telegram account.
- A telegram bot (Use BotFather to create new bot accounts if you don't have one).
- Optional: crontab as scheduler to run it on Linux machine.
$ pyhon3 updater.py
Crontab is a job scheduler on Ubuntu. Since the assignment is always due on Friday, I set the scheduler to run at minute 15 past every hour from 14 through 18 on Friday.
$ crontab -e
15 14-18 * * 5 /path/to/python3 /path/to/updater.py >> /path/to/cron.log 2>&1