Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- """
- explosm.py
- Coded by Donny
- Can be used for downloading Cynadie & Happiness comics
- """
- import urllib, re, os
- class Downloader:
- def __init__(self):
- print """
- ###########################
- #Explosm comics downloader#
- ##########################
- """
- self.comic_url = "http://explosm.net/comics/15/"
- self. run = True
- while self.run:
- self.PicandPage(self.comic_url)
- def PicandPage(self, url):
- self.arr = self.getHTML(url)
- try:
- self.split = self.find(self.arr, "http://www.explosm.net/db/files/").split('"')
- except:
- pass
- try:
- print "Downloading picture : %s" % (self.split[0])
- self.download(self.split[0])
- except:
- print "Couldn't download picture"
- try:
- print "Finding link of next page.."
- self.page = self.find(self.arr, "<a rel=\"next\" href=").split('"')
- self.comic = self.page[3].split('/')
- self.comic_url = self.comic[2]
- print "New comic's url : %s" % (self.comic_url)
- self.PicandPage("http://explosm.net/comics/"+self.comic_url+"/")
- except:
- print "Couldn't find link\nLast comic's url : %s" % (self.comic_url)
- self.run = False
- def getHTML(self, url):
- return urllib.urlopen(url).read()
- def find(self, arr, needle):
- results = re.search("("+needle+".*)", arr)
- if results:
- return results.group(1)
- else:
- return None
- def download(self, url):
- try:
- os.system("wget "+url+"")
- print "Downloaded : %s" % (url)
- except:
- print "Couldn't download!"
- Downloader()
Add Comment
Please, Sign In to add comment