2009. november 13., péntek

Twitter Backup using Bash

Here is a really simple examplescript how to backup up all your tweets into xml and then compress it with tar and gzip:


#!/bin/bash
#
# Twitter backup script using curl.
# Only worx with Bash v4.0+
# You need to know how many pages you have on twitter.
# You can get it trying this: http://twitter.com/username?page=n where n is a number.

for i in {0..n..1}
do
curl -u username:password http://twitter.com/statuses/user_timeline.xml?page=$i > twitterbackup/username-page-$i.xml
done
tar czf twitterbackup.tgz twitterbackup


You're only allowed to get your last 3200 tweets using this method. As it is written here:
Clients may request up to 3,200 statuses via the page and count parameters for timeline REST API methods.


Don't forget to follow me on twitter! :)

0 comments: