2020-06-09 00:16:00 +02:00
|
|
|
"""Classe d'accès aux données du site de l'Église
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2020-06-07 00:52:15 +02:00
|
|
|
import requests
|
2020-06-15 21:05:27 +02:00
|
|
|
import browser_cookie3
|
2020-06-07 00:52:15 +02:00
|
|
|
|
|
|
|
|
2020-06-15 21:05:27 +02:00
|
|
|
class SiteEglise:
|
2020-06-09 00:16:00 +02:00
|
|
|
|
2020-06-15 21:05:27 +02:00
|
|
|
def __init__(self, cookie_path=None):
|
|
|
|
"""
|
2020-06-09 00:16:00 +02:00
|
|
|
|
2020-06-15 21:05:27 +02:00
|
|
|
:param cookie_path: chemin vers le répertoire où inscrire les fichiers de sortie
|
|
|
|
"""
|
|
|
|
self.cookie_jar = browser_cookie3.firefox(cookie_file=cookie_path)
|
2020-06-07 00:52:15 +02:00
|
|
|
|
2020-06-15 21:05:27 +02:00
|
|
|
def get_member_list(self, unit_number):
|
|
|
|
"""Recevoir la liste des membres
|
2020-06-07 00:52:15 +02:00
|
|
|
|
2020-06-15 21:05:27 +02:00
|
|
|
:param unit_number: numéro de l'unité (paroisse, branche)
|
|
|
|
:returns: la liste des membres sous forme d'objet JSON
|
2020-06-09 00:16:00 +02:00
|
|
|
|
2020-06-15 21:05:27 +02:00
|
|
|
"""
|
|
|
|
r = requests.get('https://lcr.churchofjesuschrist.org/services/umlu/report/member-list',
|
|
|
|
params={'lang': "fra", 'unitNumber': unit_number},
|
2020-06-16 23:27:47 +02:00
|
|
|
headers={'Accept': "application/json"},
|
|
|
|
cookies=self.cookie_jar)
|
2020-06-15 21:05:27 +02:00
|
|
|
r.raise_for_status()
|
|
|
|
return r.json()
|
2020-06-09 00:16:00 +02:00
|
|
|
|
2020-06-15 21:05:27 +02:00
|
|
|
def get_member_profile(self, member_id):
|
|
|
|
"""Recevoir les informations sur un membre
|
|
|
|
|
|
|
|
:param member_id: ID du membre
|
|
|
|
:returns: les informations sur le membre sous forme d'objet JSON
|
|
|
|
|
|
|
|
"""
|
|
|
|
r = requests.get(f'https://lcr.churchofjesuschrist.org/records/member-profile/service/{member_id}',
|
|
|
|
params={'lang': "fra"},
|
|
|
|
headers={'Accept': "application/json",
|
2020-06-16 23:27:47 +02:00
|
|
|
'Referer': f"https://lcr.churchofjesuschrist.org/records/member-profile/{member_id}?lang=fra"},
|
|
|
|
cookies=self.cookie_jar)
|
2020-06-15 21:05:27 +02:00
|
|
|
r.raise_for_status()
|
|
|
|
return r.json()
|