From d1f36cb0f858849a3367eaaf3b253027a0bdbd1b Mon Sep 17 00:00:00 2001 From: Andreas <andreasv@fsmpi.rwth-aachen.de> Date: Sun, 16 Oct 2016 00:17:51 +0200 Subject: [PATCH] no longer crashing with invalid campus urls. closes #148 --- importer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/importer.py b/importer.py index f1b1738..117bb1a 100644 --- a/importer.py +++ b/importer.py @@ -32,7 +32,10 @@ def import_from(source=None, id=None): import urllib.request # if u have to port this to anything new, god be with you. for i in import_campus: - remote_html = urllib.request.urlopen(i['url']).read() + try: + remote_html = urllib.request.urlopen(i['url']).read() + except: + flash("Ungültige URL: '"+i['url']"'") tablexpath = "//td[text()='Termine und Ort']/following::table[1]" basetable = html.fromstring(remote_html).xpath(tablexpath)[0] parsebase = html.tostring(basetable); -- GitLab