Remove
As code is old most also set parser to BS eg
read()
this will let BeautifulSoup handle Unicode.As code is old most also set parser to BS eg
html.parser
or lxml
.import os, os.path from PIL import Image from bs4 import BeautifulSoup as bs path = 'C:/code/img' for root, dirs, files in os.walk(path): for f in files: soup = bs(open(os.path.join(root, f)), 'lxml') for image in soup.find_all("img"): image = image.get('src') print(image)The rest i don't care about,as it do not download so the files most be local.