2025-04-27 12:15:15 +02:00

45 lines
1.3 KiB
Python
Executable File

#!/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.generic_extractors import mobilizon
from src.agenda_culturel.import_tasks.importer import URL2Events
if __name__ == "__main__":
u2e = URL2Events(SimpleDownloader(), mobilizon.CExtractor())
url = "https://keskonfai.fr/events/166fca9c-e758-437c-8002-9a55d822e34d"
url_human = "https://keskonfai.fr/events/166fca9c-e758-437c-8002-9a55d822e34d"
try:
events = u2e.process(
url,
url_human,
cache="cache-single-event-mobilizon.html",
default_values={},
published=True,
)
exportfile = "events-single-event-mobilizon.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))