1. Steve Losh
  2. grabtweets

Commits

Steve Losh  committed 3cabf57

Fill in a couple of gaps to make a (basically) working tool.

  • Participants
  • Parent commits 2c33950
  • Branches default

Comments (0)

Files changed (1)

File grabtweets.py

View file
 
 from python_twitter import twitter
 
-#tweets = dict((s.id, s.text) for s in statuses)
-#print json.dumps(tweets)
 
 def _load_file(filename):
     if not os.path.exists(filename):
 def _get_more_tweets(username, existing_tweets):
     api = twitter.Api()
     
-    
     last_id = int(max(existing_tweets.keys())) if existing_tweets else 0
     first_id = int(min(existing_tweets.keys())) if existing_tweets else None
     
-    statuses = api.GetUserTimeline(username, max_id=first_id, count=5)
+    statuses = api.GetUserTimeline(username, max_id=first_id, count=200)
     existing_tweets.update(dict((s.id, s.text) for s in statuses))
     
-    statuses = api.GetUserTimeline(username, since_id=0, count=5)
+    statuses = api.GetUserTimeline(username, since_id=0, count=200)
     existing_tweets.update(dict((s.id, s.text) for s in statuses))
     
     return existing_tweets
     tweets = _load_file(args[0])
     
     if options.print_tweets:
-        print tweets
-        for tid in tweets:
-            print tid, tweets[tid]
-            print ''
+        tweets = sorted([(tid, tweets[tid]) for tid in tweets])
+        for tid, text in tweets:
+            print tid, text, '\n'
         return
     
     if not options.username: