Created
August 21, 2015 15:20
-
-
Save clamytoe/ed3e39e5e943d10c359c to your computer and use it in GitHub Desktop.
While developing my memory game for a Python class, I was in need of some nice icon images. I scraped the image tags from http://snwh.org/paper/icons/ and saved them as paper_icons.html. I then wrote this script to download them...
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 urllib2 | |
fname = 'paper_icons.html' | |
handle = open(fname, 'r') | |
images = list() | |
count = 0 | |
for line in handle: | |
line = line.rstrip() | |
tags = line.split() | |
for tag in tags: | |
if tag.startswith('src='): | |
junk, link = tag.split('=') | |
link = link.split('"')[1] | |
images.append(link) | |
def show_image_links(): | |
global count | |
for link in images: | |
count += 1 | |
print "[" + str(count).rjust(2, '0') + "] " + link.split('/')[-1] | |
def download_images(): | |
for image in images: | |
url = image | |
file_name = url.split('/')[-1] | |
u = urllib2.urlopen(url) | |
f = open(file_name, 'wb') | |
meta = u.info() | |
file_size = int(meta.getheaders("Content-Length")[0]) | |
print "Downloading: %s Bytes: %s" % (file_name, file_size) | |
file_size_dl = 0 | |
block_sz = 8192 | |
while True: | |
buffer = u.read(block_sz) | |
if not buffer: | |
break | |
file_size_dl += len(buffer) | |
f.write(buffer) | |
status = r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size) | |
status += chr(8)*(len(status)+1) | |
print status, | |
f.close() | |
if __name__ == '__main__': | |
show_image_links() | |
# download_images() # uncomment to download the icons |
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
<img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/accessories-dictionary.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/accessories-calculator.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/accessories-notes.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/accessories-text-editor.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/applets-screenshooter.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/color-picker.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/disk-burner.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/disk-utility.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/document-viewer.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/firefox.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/google-chrome.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/help-browser.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/internet-mail.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/internet-web-browser.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/irc-chat.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/places/user-home.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/places/workspace-switcher-top-left.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/multimedia-audio-player.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/multimedia-photo-viewer.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/multimedia-video-player.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/multitasking-view.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/office-calendar.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/preferences-color.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/preferences-desktop.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/preferences-desktop-font.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/preferences-desktop-theme.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/preferences-system-brightness-lock.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/preferences-system-search.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/preferences-system-time.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/preferences-system-windows.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/software-store.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/sound-recorder.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/system-file-manager.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/system-software-update.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/utilities-system-monitor.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/utilities-tweak-tool.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/utilities-terminal.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/apps/vlc.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/categories/preferences-desktop-locale.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/categories/preferences-desktop-online-accounts.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/categories/preferences-system-power.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/devices/bluetooth.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/devices/camera-photo.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/devices/input-gaming.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/devices/input-keyboard.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/devices/media-optical.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/devices/network-vpn.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/devices/network-wireless.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/devices/printer.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/status/image-missing.png" alt=""><img class="animated delay zoomIn hicolor-image" src="https://raw.githubusercontent.com/snwh/paper-icon-theme/master/Paper/96x96/status/network-error.png" alt=""> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment