#!/usr/bin/env python3
from bs4 import BeautifulSoup
import os
file_list = []
for root, dirs, files in os.walk("."):
for file in files:
if file.endswith(".html"):
file_list += [os.path.join(root, file)]
image_list = []
image_folder_list = []
for i in file_list:
dir_path = os.path.dirname(os.path.realpath(i))
file_in = open(i, 'r')
soup = BeautifulSoup(file_in, 'html.parser')
all_imgs = soup.find_all('img')
for image in all_imgs:
source = image['src']
if source[0] != "/" and os.path.isfile(dir_path + '/' + source):
img_path = os.path.realpath(dir_path + '/' + source)
img_dir_path = os.path.dirname(img_path)
if img_path not in image_list:
image_list += [img_path]
if img_dir_path not in image_folder_list:
image_folder_list += [img_dir_path]
all_images = []
for i in image_folder_list:
for root, dirs, files in os.walk(i):
for file in files:
if file.endswith(".png"):
all_images += [os.path.join(root, file)]
for i in image_list:
if i not in all_images:
print(i)