Commit 26082ca7 authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files

tools/ simple href link validation

See #3364.
parent c8d2b8e2
import requests
import glob
import sys
from urllib.parse import *
import re
DEFAULT_FILES = glob.glob('../site/*/*.html')
REGEX_HREF = re.compile('href="(.*?)"')
None: '? ',
False: 'KO',
True: 'ok'
def check_url(url):
if not url.startswith('http'):
return None
req = requests.get(url)
return (req.status_code < 400)
return False
def check_file(f):
print('<-- ', f)
content = ''.join(open(f).readlines())
for url in REGEX_HREF.findall(content):
ok = check_url(url)
print(STATUS[ok] + ' ' + url)
if __name__ == '__main__':
files = sys.argv[1:] if len(sys.argv) > 1 else DEFAULT_FILES
for f in files:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment