Yeah, I know it's late, but I got obsessed and couldn't turn away. Now I have a really slick python script that pulls down the latest Questionable Content strip and adds it to my collection to read later:
#!/usr/bin/env python
import os, sys, re
import pycurl, urllib2
destination = "/path/to/qc/repository"
class QC:
def __init__(self):
self.contents = ''
self.baseurl = 'http://questionablecontent.net/'
def callback(self,buf):
self.contents = self.contents + buf
def end(self):
c = pycurl.Curl()
c.setopt(c.URL, self.baseurl)
c.setopt(c.WRITEFUNCTION, self.callback)
c.perform()
c.close()
try:
return int(re.search('.*\/comics\/(\d+)\.png', self.contents).group(1))
except:
print ""
print " The regular expression no longer works."
print " You might want to check into that."
print ""
exit()
def fetch(self,n):
strip = urllib2.build_opener().open(self.baseurl + 'comics/' + str(n) + ".png").read()
f = "%s%s%04d%s" % (destination, "/", n, ".png")
fout = open(f, "wb")
fout.write(strip)
fout.close()
# Main -----------------------------------------------------------------------
qc = QC()
for i in range(1, qc.end() + 1):
f = "%s%s%04d%s" % (destination, "/", i, ".png")
if not os.path.exists(f):
print "Fetching strip #" + str(i)
qc.fetch(i)
