Ajout import Helloasso
This commit is contained in:
50
experimentations/get_helloasso.py
Executable file
50
experimentations/get_helloasso.py
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/python3
|
||||
# coding: utf-8
|
||||
|
||||
# To be able to run this import out of django, you'll have to set an environment variable with the Helloasso client id/secret:
|
||||
# export HELLOASSO_SECRET=<your secret>
|
||||
# export HELLOASSO_ID=<your ID>
|
||||
|
||||
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.helloasso import (
|
||||
CExtractor,
|
||||
)
|
||||
from src.agenda_culturel.import_tasks.importer import URL2Events
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
u2e = URL2Events(SimpleDownloader(), CExtractor())
|
||||
#url = "https://www.helloasso.com/associations/federation-des-associations-laiques-du-puy-de-dome/evenements/de-fil-en-chemin-2025-11e-edition-rencontres-de-danse-amateur"
|
||||
url = "https://www.helloasso.com/associations/federation-des-associations-laiques-du-puy-de-dome"
|
||||
|
||||
url_human = url
|
||||
|
||||
events = u2e.process(
|
||||
url,
|
||||
url_human,
|
||||
cache="cache-helloasso.html",
|
||||
default_values={},
|
||||
published=True,
|
||||
)
|
||||
|
||||
exportfile = "events-helloasso.json"
|
||||
print("Saving events to file {}".format(exportfile))
|
||||
with open(exportfile, "w") as f:
|
||||
json.dump(events, f, indent=4, default=str)
|
Reference in New Issue
Block a user