Skip to content

Instantly share code, notes, and snippets.

@compbrain
Created December 13, 2010 11:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save compbrain/738917 to your computer and use it in GitHub Desktop.
Save compbrain/738917 to your computer and use it in GitHub Desktop.
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