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:
#!/usr/bin/python
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 = f.read()
a = 0
while a < 100:
ls = text.rfind(' ', 0, 140)
post = text[0:ls]
log(post)
postToTwitter(post)
text = text[ls+1:]
a = a + 1
time.sleep(30)
def postToTwitter(text):
auth = urllib2.HTTPPasswordMgrWithDefaultRealm()
auth.add_password(None, 'http://twitter.com/statuses/', twitter_username, twitter_password)
authHandler = urllib2.HTTPBasicAuthHandler(auth)
opener = urllib2.build_opener(authHandler)
urllib2.install_opener(opener)
url = 'http://twitter.com/statuses/update.xml'
post = {'status':text}
post = urllib.urlencode(post)
request = urllib2.Request(url, post)
resp = urllib2.urlopen(request).read()
if __name__ == "__main__":
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!
:-)
-Russ