Skip to content

Instantly share code, notes, and snippets.

@gleitz
Created October 26, 2011 16:45
Show Gist options
  • Save gleitz/1316945 to your computer and use it in GitHub Desktop.
Save gleitz/1316945 to your computer and use it in GitHub Desktop.
import urllib
import urllib2
from BeautifulSoup import BeautifulSoup as bs
def get_backgrounds():
base = 'http://thefoxisblack.com/category/the-desktop-wallpaper-project/page/%s/'
for x in range(0, 36):
get_images_from_page(base % (x + 1))
def get_images_from_page(url):
html = fetchurl(url)
soup = bs(html)
for link in soup.findAll('a'):
href = link['href']
if '-1440x900' in href:
print 'Downloading %s' % href
urllib.urlretrieve(href, '/Users/gleitz/Desktop/fox_backgrounds%s' % href[href.rfind('/'):])
def fetchurl(url):
response = urllib2.urlopen(url)
return response.read()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment