diff options
Diffstat (limited to 'management/commands/scraptimetables.py')
-rw-r--r-- | management/commands/scraptimetables.py | 9 |
1 files changed, 8 insertions, 1 deletions
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) |