Skip to content

Instantly share code, notes, and snippets.

@johnpena
Created November 6, 2010 23:30
Show Gist options
  • Save johnpena/665801 to your computer and use it in GitHub Desktop.
Save johnpena/665801 to your computer and use it in GitHub Desktop.
Archives your stuff from Instapaper. This saves the archive as a mobi file, but you can change that by replacing the last URL.
import urllib, urllib2
import cookielib
def getInstapaperArchive(username, password):
login_url = "http://www.instapaper.com/user/login"
home_url = "http://www.instapaper.com/u"
kindle_url = "http://www.instapaper.com/mobi"
params = {"username":username, "password":password}
post_data = urllib.urlencode(params)
redirect_handler = urllib2.HTTPRedirectHandler()
cookiejar = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar), redirect_handler)
login_response = opener.open(login_url, post_data)
home_response = opener.open(home_url)
kindle_response = opener.open(kindle_url)
return kindle_response
if __name__ == '__main__':
from datetime import date
save_file = '/your/save/dir/Instapaper_%s.mobi' % str(date.today())
f = file(save_file, 'w')
data = getInstapaperArchive("your@email.com", "instapaperpassword")
f.write(data.read())
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment