The Great American Novel in 140 Character Installments


Jonathan responded to some posts I had written yesterday via Twitter with a "STFU" and when I asked what I said, he responded: "J/k, I just left my computer for 30min and came back to the great american novel in 140 char installments ;-)".

Awesome idea!

Thus I am currently logging the entirety of The Catcher In The Rye to Twitter (using my own ID no less!), in 140 character installments, every 30 seconds. Actually, I'm only logging the first 14,000 characters, but it'll be interested who sticks around for it... I started with 261 followers. We'll see how many are left at the end. :-)

I grabbed the text for the novel off of Scribd - which is easily the best place to find eBooks (legal or not) on the web - and then wrote up this quick Python script:


import sys
import time
import urllib, urllib2

twitter_username = 'name'
twitter_password = 'pass'

def log(s):
    print s

def main():
    f=open('./catcher.txt', 'r')

    text =

    a = 0

    while a < 100:
        ls = text.rfind(' ', 0, 140)
        post = text[0:ls]
        text = text[ls+1:]
        a = a + 1

def postToTwitter(text):

    auth = urllib2.HTTPPasswordMgrWithDefaultRealm()
    auth.add_password(None, '', twitter_username, twitter_password)
    authHandler = urllib2.HTTPBasicAuthHandler(auth)

    opener = urllib2.build_opener(authHandler)

    url = ''

    post = {'status':text}
    post = urllib.urlencode(post)

    request = urllib2.Request(url, post)

    resp = urllib2.urlopen(request).read()

if __name__ == "__main__":

I even made sure to split on the spaces so I didn't cut words in half... I'm starting to like Python after all!



< Previous         Next >