Download All Images from a Remote Directory : Python Script

Here’s a quick Python script which you can use to download all images from a remote directory say from I have used beautiful soup to do all the heavy-lifting.

from BeautifulSoup import BeautifulSoup as bs
import urlparse
from urllib2 import urlopen
from urllib import urlretrieve
import os
import sys

def main(url, out_folder="D:/deckfinal/"):
    soup = bs(urlopen(url))
    for image in soup.findAll("a"):
        parsed =  url+image['href']
        filename = image['href']
        outpath = os.path.join(out_folder, filename)
            urlretrieve(parsed, outpath)
            print "skipping" + parsed
if __name__ == "__main__":
    main("", "D://myimages")

By Bhaskar

My name is Bhaskar. I am a CTO and a startup techno guy with 10+ years of experience startups.
Full-time coding in Python, React, Java. Part-time coding in C++.
Interested in Music, Travelling

What excites me: anything that has the potential to disrupt the status quo.

Looking for technical support on a startup idea ?
write at : bhaskar {-at-}