Skip to content
Extraits de code Groupes Projets
Valider 180ce34c rédigé par Bastien Le Querrec's avatar Bastien Le Querrec
Parcourir les fichiers

pref34: détecte l'URL de l'année voulue automatiquement

parent 8a40c7e0
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -11,14 +11,7 @@ class Attrap_pref34(Attrap): ...@@ -11,14 +11,7 @@ class Attrap_pref34(Attrap):
# Config # Config
__HOST = 'https://www.herault.gouv.fr' __HOST = 'https://www.herault.gouv.fr'
__RAA_PAGE = { __RAA_PAGE = f'{__HOST}/Publications/Recueils-des-actes-administratifs'
'2024': f'{__HOST}/Publications/Recueils-des-actes-administratifs/Recueil-des-actes-administratifs-2024',
'2023': f'{__HOST}/Publications/Recueils-des-actes-administratifs/Recueil-des-actes-administratifs-2023',
'2022': f'{__HOST}/Publications/Recueils-des-actes-administratifs/Recueil-des-actes-administratifs-2022',
'2021': f'{__HOST}/Publications/Recueils-des-actes-administratifs/Recueil-des-actes-administratifs-2021',
'2020': f'{__HOST}/Publications/Recueils-des-actes-administratifs/Recueil-des-actes-administratifs-2020',
'2019': f'{__HOST}/Publications/Recueils-des-actes-administratifs/Archives/Recueil-des-actes-administratifs-2019'
}
__USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; rv:109.0) Gecko/20100101 Firefox/115.0' __USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; rv:109.0) Gecko/20100101 Firefox/115.0'
full_name = 'Préfecture de l\'Hérault' full_name = 'Préfecture de l\'Hérault'
short_code = 'pref34' short_code = 'pref34'
...@@ -29,18 +22,18 @@ class Attrap_pref34(Attrap): ...@@ -29,18 +22,18 @@ class Attrap_pref34(Attrap):
def get_raa(self, keywords): def get_raa(self, keywords):
pages_to_parse = [] pages_to_parse = []
if self.not_before.year <= 2024:
pages_to_parse.append(self.__RAA_PAGE['2024']) year_pages = self.get_sub_pages_with_pager(
if self.not_before.year <= 2023: self.__RAA_PAGE,
pages_to_parse.append(self.__RAA_PAGE['2023']) 'div.fr-card.fr-card--horizontal.fr-card--sm.fr-enlarge-link.fr-mb-3w div.fr-card__body div.fr-card__content h2.fr-card__title a.fr-card__link',
if self.not_before.year <= 2022: 'ul.fr-pagination__list li a.fr-pagination__link.fr-pagination__link--next.fr-pagination__link--lg-label',
pages_to_parse.append(self.__RAA_PAGE['2022']) 'div.fr-card.fr-card--horizontal.fr-card--sm.fr-enlarge-link.fr-mb-3w div.fr-card__body div.fr-card__content div.fr-card__end p.fr-card__detail',
if self.not_before.year <= 2021: self.__HOST
pages_to_parse.append(self.__RAA_PAGE['2021']) )
if self.not_before.year <= 2020: for year_page in year_pages:
pages_to_parse.append(self.__RAA_PAGE['2020']) year = Attrap.guess_date(year_page['name'], '.*([0-9]{4})').year
if self.not_before.year <= 2019: if year >= self.not_before.year:
pages_to_parse.append(self.__RAA_PAGE['2019']) pages_to_parse.append(year_page['url'])
elements = [] elements = []
for raa_page in pages_to_parse: for raa_page in pages_to_parse:
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter