From 20c5b985beab57d71f5b10e6f2a1aeb23e806259 Mon Sep 17 00:00:00 2001 From: Sebastian Lay Date: Fri, 11 Nov 2022 17:22:13 +0100 Subject: [PATCH] Added script to identify broken links --- scripts/broken-links.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 scripts/broken-links.py diff --git a/scripts/broken-links.py b/scripts/broken-links.py new file mode 100644 index 0000000..10905e1 --- /dev/null +++ b/scripts/broken-links.py @@ -0,0 +1,18 @@ +import json +import time +from urllib.request import urlopen + +with open('js/current-films.js', mode='r') as file: + file_content = file.read() + +films = json.loads(file_content[19:]) + +for film in films: + time.sleep(1) + if film['lomography']: + try: + with urlopen(film['lomography']) as response: + print(film['name'] + ' ✓') + except: + print(film['name'] + ' ✗ - ' + film['lomography']) +