Python Forum
HTML - Save Images From Folder - PIL
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HTML - Save Images From Folder - PIL
#2
Remove 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.
Reply


Messages In This Thread
HTML - Save Images From Folder - PIL - by dj99 - Jul-15-2018, 10:55 AM
RE: HTML - Save Images From Folder - PIL - by snippsat - Jul-15-2018, 02:21 PM
RE: HTML - Save Images From Folder - PIL - by dj99 - Jul-15-2018, 03:12 PM
RE: HTML - Save Images From Folder - PIL - by dj99 - Jul-15-2018, 05:45 PM
RE: HTML - Save Images From Folder - PIL - by dj99 - Jul-17-2018, 07:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  HTML multi select HTML listbox with Flask/Python rfeyer 0 4,654 Mar-14-2021, 12:23 PM
Last Post: rfeyer
  cant access root environment folder from django folder using __init__.py Sanjish 0 1,919 Dec-25-2020, 05:56 AM
Last Post: Sanjish
  Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to loop to next HTML/new CSV Row BrandonKastning 0 2,381 Mar-22-2020, 06:10 AM
Last Post: BrandonKastning
  flask app to save images locally when deployed on heroku not working Prince_Bhatia 1 5,285 Feb-20-2019, 11:59 PM
Last Post: snippsat
  how i save the html form to flask database mebaysan 1 7,314 Feb-07-2019, 12:56 AM
Last Post: snippsat
  Execute using Html, Save data into Database and Download in CSV in Django --Part 1 Prince_Bhatia 0 3,846 Jan-19-2018, 06:05 AM
Last Post: Prince_Bhatia

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020