diff --git a/macli.py b/macli.py index f0a7c9e..e3d595e 100644 --- a/macli.py +++ b/macli.py @@ -52,6 +52,9 @@ def relink_css(content, base_url, directory='styles'): def relink_images(content, base_url, directory='images'): os.makedirs(directory, exist_ok=True) for image in content.find_all('img'): + if 'src' not in image.attrs: + continue + src = urllib.parse.urljoin(base_url, image['src'], allow_fragments=False) name = hashlib.sha1(src.encode()).hexdigest() + '.' + get_extension(src) @@ -67,6 +70,9 @@ def relink_images(content, base_url, directory='images'): def relink_scripts(content, base_url, directory='scripts'): os.makedirs(directory, exist_ok=True) for script in content.find_all('script'): + if 'src' not in script.attrs: + continue + href = urllib.parse.urljoin(base_url, script['src'], allow_fragments=False) name = hashlib.sha1(href.encode()).hexdigest() + '.' + get_extension(href)