Zakkq

xkcd Comic Downloader

May 30th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. import re,os,urllib2,os.path
  2. for i in range(len(re.findall('a href=".*?title=".*?',urllib2.urlopen("http://www.xkcd.com/archive/").read()))):
  3.         if not os.path.isfile(r"B:\Images\xkcd"+"\ "+str(i+1)+".png"):
  4.             with open(r"B:\Images\xkcd"+"\ "+str(i+1)+".png",'wb+') as o:
  5.                 o.write(urllib2.urlopen("http://"+re.findall('<img.*?src="//imgs.xkcd.com/comics/.*?"',urllib2.urlopen("http://www.xkcd.com/{0}/".format(i+1)).read())[0].split("//")[1][:-1]).read())
Add Comment
Please, Sign In to add comment