Hello s,
when i use this line to check the path
print(os.path.join(root, image))
i get the correct path
eg
c:/Users/Dan/Desktop/a/images/image001.jpg
When I use it in the complete code.
The image does not get saved
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 77: character maps to <undefined>
using the html file below
when i use this line to check the path
print(os.path.join(root, image))
i get the correct path
eg
c:/Users/Dan/Desktop/a/images/image001.jpg
When I use it in the complete code.
The image does not get saved
import os, os.path from PIL import Image from bs4 import BeautifulSoup as bs path = 'c:/Users/Dan/Desktop/a/' 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') #im = Image.open(os.path.join(root, image["src"])) im = Image.open(os.path.join(root, image)) #["src"])) im.save(path+image, "png") # < < < Image not saving # print(os.path.join(root, image))Unicode error
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 77: character maps to <undefined>
using the html file below
<!DOCTYPE html> <html> <body> <h2>HTML Image</h2> <img src="images/image001.jpg" alt="Flowers in Chania" width="460" height="345"> </body> </html>
:)
Python newbie trying to learn the ropes