Skip to content

Instantly share code, notes, and snippets.

@ignamv
Created February 13, 2022 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ignamv/407f6b5408e78f4d7095b2685df0a2ec to your computer and use it in GitHub Desktop.
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
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