Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Download simpledesktops wallpapers
#!/usr/bin/python
"""Download a whole page of wallpapers from simpledesktops.com.
Requires:
- BeautifulSoup: http://www.crummy.com/software/BeautifulSoup/#Download
Usage:
$ ./simpledesktops_download.py "http://simpledesktops.com/browse/6/"
Downloading http://parsed.url.com/directory/subdir/wallpaper.png to wallpaper.png
- Please be gentle when downloading files.
- Browse around their site to give them support!
"""
__author__ = "Will Nowak <wan@ccs.neu.edu>"
import urllib
import urlparse
import os
from BeautifulSoup import BeautifulSoup
import sys
b = BeautifulSoup(urllib.urlopen(sys.argv[1]).read())
for x in b.findAll(attrs={'class':'desktop'}):
uri = x.find('a')['href']
parsed = urlparse.urlparse(uri)
f = os.path.basename(parsed.path)
print 'Downloading %s to %s' % (uri, f)
urllib.urlretrieve(x.find('a')['href'], f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.