Skip to content

Instantly share code, notes, and snippets.

View plux's full-sized avatar

Håkan Nilsson plux

View GitHub Profile
@plux
plux / random_imgur.py
Created July 13, 2012 20:59
random imgur tinyer
import os,random,string,sys,urllib2
n=5if len(sys.argv)<2 else int(sys.argv[1])
while n>0:
s=''.join(random.sample(string.letters+string.digits,5))+'.jpg'
i=urllib2.urlopen('http://i.imgur.com/'+s).read()
if len(i)!=503:n-=1;open('output/'+s,'wb').write(i)
@plux
plux / random_imgur.py
Created July 13, 2012 20:40
random_imgur tiny
import os, random, string, sys, urllib2
num_pics = 5
if len(sys.argv) > 1:
num_pics = int(sys.argv[1])
while num_pics > 0:
name = ''.join(random.sample(string.letters+string.digits, 5)) + '.jpg'
img = urllib2.urlopen("http://i.imgur.com/" + name).read()
if len(img) != 503: # 'image not found' is 503 bytes