Skip to content

Instantly share code, notes, and snippets.

@corentinbettiol
Last active October 29, 2020 13:55
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 corentinbettiol/f8373a76bf4d1aaf5493d8e3afc0e2d9 to your computer and use it in GitHub Desktop.
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!
#!/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)
@corentinbettiol
Copy link
Author

corentinbettiol commented Oct 29, 2020

image

Install

python3 -m pip install requests beautifulsoup4
wget https://gist.githubusercontent.com/corentinbettiol/f8373a76bf4d1aaf5493d8e3afc0e2d9/raw/a0a19c3fce56b58be444a264ca3e0f5a4828c3e8/bouchons.py
chmod +x bouchons.py

Use

Use like this :

  • nohup ./bouchons.py &
  • close terminal
  • enjoy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment