Skip to content

Instantly share code, notes, and snippets.

@Pacek
Created April 28, 2012 10:48
Show Gist options
  • Save Pacek/2517912 to your computer and use it in GitHub Desktop.
Save Pacek/2517912 to your computer and use it in GitHub Desktop.
Download all wallpapears from simpledesktops.com
"""
This handy script will download all wallpapears from simpledesktops.com
Requirements
============
BeautifulSoup - http://www.crummy.com/software/BeautifulSoup/
Python-Requests - http://docs.python-requests.org/en/latest/index.html
Usage
=====
cd /path/to/the/script/
python simpledesktops.py
"""
from StringIO import StringIO
from bs4 import BeautifulSoup
import requests
import os
try:
os.mkdir('walls')
except OSError:
pass
page = 1
while True:
page_request = requests.get('http://simpledesktops.com/browse/%s/' % page)
if page_request.status_code != 200:
print 'page %s does not exist' % page
break
html = BeautifulSoup(page_request.text)
images = html.findAll('img')
for image in images:
img_src = image['src']
if 'static.simpledesktops.com/desktops/' in img_src:
full_size_img = img_src.replace('.295x184_q100.png', '')
img_name = full_size_img.split('/')[-1]
img_request = requests.get(full_size_img)
img_buffer = StringIO(img_request.content)
img_file = open('walls/%s' % img_name, 'wb')
img_file.write(img_buffer.getvalue())
img_file.close()
print '%s downloaded' % img_name
print '\n================'
print 'page %s finished' % page
print '================\n'
page += 1
@dvs23
Copy link

dvs23 commented Jul 30, 2017

New URL: static.simpledesktops.com/uploads/desktops/
instead of static.simpledesktops.com/desktops/
in line 35!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment