From afa67de3f2b8cb01d4565ad9dd438155b4023f09 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sat, 9 Sep 2017 21:04:12 +0200 Subject: Rajout des emplois du temps dans la base --- management/commands/scraptimetables.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'management/commands') diff --git a/management/commands/scraptimetables.py b/management/commands/scraptimetables.py index 780ea8d..255bfd4 100644 --- a/management/commands/scraptimetables.py +++ b/management/commands/scraptimetables.py @@ -34,7 +34,14 @@ class Command(BaseCommand): if "toutes sections et semestres confondus" in link.text: url_base = finder.rsplit("/", 1) timetable_url = "/".join([url_base[0], link.parent.parent.find("a", attrs={"class": "xmllink"})["href"]]) - print(year, name, link.text, timetable_url) + + try: + timetable = Timetable.objects.get(year=year, name=name) + timetable.url = timetable_url + except: + timetable = Timetable(year=year, name=name, url=timetable_url) + finally: + timetable.save() def __get_finders(self, url): soup = get_xml(url) -- cgit v1.2.1