Last active
October 29, 2020 13:55
-
-
Save corentinbettiol/f8373a76bf4d1aaf5493d8e3afc0e2d9 to your computer and use it in GitHub Desktop.
Get traffic jams numbers from Ile de France in real time as notifications!
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
#!/usr/bin/python3 | |
from bs4 import BeautifulSoup | |
from requests import get | |
from os import system | |
from time import sleep | |
km = "0" | |
while 1: | |
content = get("http://www.sytadin.fr/sys/barometre_courbe_cumul.jsp.html") | |
soup = BeautifulSoup(content.text, features="lxml") | |
bouchons = soup.find_all("strong") | |
if len(bouchons): | |
bouchons = ( | |
bouchons[0] | |
.text.replace("<strong>", "") | |
.replace("</strong>", "") | |
.strip() | |
.replace(" km", "") | |
) | |
if bouchons != km: | |
if int(km) > int(bouchons): | |
s = "Baisse de " + str(int(km) - int(bouchons)) + "km." | |
else: | |
s = "Hausse de " + str(int(bouchons) - int(km)) + "km." | |
km = bouchons | |
system('notify-send "' + km + "km de bouchons...\n" + s + '"') | |
sleep(60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install
Use
Use like this :
nohup ./bouchons.py &