Initial commit

Cette révision appartient à :
Lucas Verney 2018-12-14 10:51:43 +01:00
révision dcc774b92f
5 fichiers modifiés avec 91 ajouts et 0 suppressions

1
.gitignore externe Fichier normal
Voir le fichier

@ -0,0 +1 @@
lastrun.json

21
LICENSE.md Fichier normal
Voir le fichier

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2018 Phyks (Lucas Verney)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

5
README.md Fichier normal
Voir le fichier

@ -0,0 +1,5 @@
Montrouge
=========
These are just some helper scripts to fetch documents and notify about updates
from the official Website of the Montrouge City (http://ville-montrouge.fr/).

61
montrouge.py Fichier normal
Voir le fichier

@ -0,0 +1,61 @@
# coding: utf-8
import json
import sys
import bs4 as BeautifulSoup
import requests
data = {
"comitesDeQuartier": {
"Ferry-Buffalo": [],
"Jean Jaurès": [],
"Plein Sud": [],
"Portes de Montrouge": [],
"Montrouge Est": [],
"Vieux Montrouge": [],
},
"conseilsMunicipaux": []
}
# Get Conseils Municipaux
r = requests.get(
"https://www.ville-montrouge.fr/621-les-seances-publiques-et-deliberations.htm"
)
soup = BeautifulSoup.BeautifulSoup(r.text, features='lxml')
main= soup.find('main', attrs={"id": "corps"})
table = main.find('table')
a = table.findAll('a')
data["conseilsMunicipaux"] = ["https://www.ville-montrouge.fr" + x.attrs['href'] for x in a]
# Handle Comités de Quartier
URLS = {
"Ferry-Buffalo": "https://www.ville-montrouge.fr/688-comite-ferry-buffalo.htm",
"Jean Jaurès": "https://www.ville-montrouge.fr/689-comite-jean-jaures.htm",
"Plein Sud": "https://www.ville-montrouge.fr/692-comite-plein-sud.htm",
"Portes de Montrouge": "https://www.ville-montrouge.fr/690-comite-portes-de-montrouge.htm",
"Montrouge Est": "https://www.ville-montrouge.fr/691-comite-montrouge-est.htm",
"Vieux Montrouge": "https://www.ville-montrouge.fr/693-comite-vieux-montrouge.htm",
}
for (k, url) in URLS.items():
r = requests.get(url)
soup = BeautifulSoup.BeautifulSoup(r.text, features='lxml')
div = soup.find('div', attrs={"class": "enSavoirPlusParagraphe PRS_ENCADRE txt"})
if div:
a = div.findAll('a')
data["comitesDeQuartier"][k] = ["https://www.ville-montrouge.fr" + x.attrs['href'] for x in a]
dump = json.dumps(data, sort_keys=True,
indent=4, separators=(',', ': '))
try:
with open('lastrun.json', 'r') as fh:
lastrun = fh.read()
# If something changed, print the fetched data and exit 1 to ensure chronic
# sends an email.
if lastrun != dump:
print(dump)
sys.exit(1)
except IOError:
pass
with open('lastrun.json', 'w') as fh:
fh.write(dump)

3
requirements.txt Fichier normal
Voir le fichier

@ -0,0 +1,3 @@
bs4
lxml
requests