#!/usr/bin/python3 # coding: utf-8 import json import os import sys # getting the name of the directory # where the this file is present. current = os.path.dirname(os.path.realpath(__file__)) # Getting the parent directory name # where the current directory is present. parent = os.path.dirname(current) # adding the parent directory to # the sys.path. sys.path.append(parent) sys.path.append(parent + "/src") from src.agenda_culturel.import_tasks.downloader import SimpleDownloader from src.agenda_culturel.import_tasks.extractor import iguana_agenda from src.agenda_culturel.import_tasks.importer import URL2Events if __name__ == "__main__": u2e = URL2Events(SimpleDownloader(), iguana_agenda.CExtractor()) url = "https://bibliotheques-clermontmetropole.eu/iguana/Service.PubContainer.cls?uuid=a4a1f992-06da-4ff4-9176-4af0a095c7d1" url_human = "https://bibliotheques-clermontmetropole.eu/iguana/www.main.cls?surl=AGENDA_Tout%20lagenda" try: events = u2e.process( url, url_human, cache="cache-mediatheques.html", default_values={}, published=True, ) exportfile = "events-mediatheques.json" print("Saving events to file {}".format(exportfile)) with open(exportfile, "w") as f: json.dump(events, f, indent=4, default=str) except Exception as e: print("Exception: " + str(e))