Created
October 26, 2011 16:45
-
-
Save gleitz/1316945 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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