How to save pictures from a website to a local folder

前端 未结 3 578
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-21 12:28

I\'d need to save pictures from this website in a folder:

http://www.photobirdireland.com/garden-birds.html

I\'ve tried by using import os

from l         


        
3条回答
  •  我在风中等你
    2021-01-21 13:08

    this html = urlopen(url) should be html = urlopen(self.url)

    edit: you can fetch the urls like this

    def scrape_images(self):
           html = urlopen(selfurl)
           bs4 = bs(html, 'html.parser')
    
           urls = []
           for img in bs4.find_all('img'):
               urls.append(img.attrs.get("src"))
    
           return urls
    

    and the next step would be finding out how to download them.

提交回复
热议问题