I thought I’d share this little piece of code. Nothing revolutionary, but all right for Twitter maintenance. I didn’t want to be following lots of people that don’t post, so I wrote this little utillity that lists when people posted last time. It requires python-twitter. To get a nice list of who hasn’t posted in 2009, do
python lasttweet.py | grep -v 2009
Likewise, if you want to see everyone that last posted in January and have it sorted by what day in January, do:
python lasttweet.py |grep Jan|cut -d ' ' -f 3-9|sort -n
Here follows the code:
`
api = twitter.Api(username=’username’, password=’somepassword’)
page = 1
users = api.GetFriends(page=1)
friends = []
friends = friends + users
while(len(users) == 100):
  page = page + 1
  users = api.GetFriends(page=page)
  friends = friends + users

for user in friends:
  lastPost = user.GetStatus().AsDict()[“created_at”]
  print lastPost, user.screen_name
  tl = api.GetPublicTimeline(user.name)
`

Categories: Technology