Created
February 13, 2022 09:45
-
-
Save ignamv/407f6b5408e78f4d7095b2685df0a2ec to your computer and use it in GitHub Desktop.
Poll whether exam vacancies are still available for Goethe B1 exam in Münchner Volkshochschule, show message if not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import subprocess | |
import datetime | |
from bs4 import BeautifulSoup | |
def are_there_free_places(html): | |
soup = BeautifulSoup(html, 'html.parser') | |
places = soup.find(**{'data-label': 'Plätze: '}).text.strip() | |
return places == 'Noch Plätze frei' | |
def notify_send(message): | |
subprocess.check_call(['notify-send', '-t', '0', message], env={'DISPLAY': ':0'}) | |
url = 'https://www.mvhs.de/programm/deutsch-integration/goethe-zertifikat-b1.20152/O671220' | |
html = requests.get(url).text | |
places_free = are_there_free_places(html) | |
if not places_free: | |
notify_send('Few places left') | |
with open('log.txt', 'a') as fd: | |
time = datetime.datetime.now().isoformat() | |
fd.write(f'{time}\t{places_free}\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment