From e80ab8a7232a73d8a0f09f8e41a88893d4c65d63 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Tue, 10 Oct 2017 21:26:39 +0200 Subject: Envoi d’un user-agent personnalisé --- management/commands/_private.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/management/commands/_private.py b/management/commands/_private.py index 3b6a164..943a3fb 100644 --- a/management/commands/_private.py +++ b/management/commands/_private.py @@ -23,6 +23,7 @@ from edt.models import Group, Room, Course from edt.utils import get_week import requests +import edt def add_time(date, time): ptime = datetime.datetime.strptime(time, "%H:%M") @@ -194,7 +195,8 @@ def get_weeks(soup): return weeks def get_xml(url): - req = requests.get(url) + user_agent = "celcatsanitizer/" + edt.VERSION + req = requests.get(url, headers={"User-Agent": user_agent}) req.encoding = "utf8" soup = BeautifulSoup(req.content, "html.parser") -- cgit v1.2.1