Jump to content

Twitter public timeline grabber - bash script, for use with cron etc


Guest glossywhite

Recommended Posts

Guest glossywhite

Okay, so I wrote this nice little bash script, for grabbing current comments from the public Twitter timeline, and adding them to a text file:

#!/bin/bash

## twitter public timeline grabber

grab=`curl -s http://twitter.com/statuses/public_timeline.rss | grep title | sed -e 's/<title>//' | sed -e 's/<\/title>//' | sed -e 's/&#.*//'`


if [ -f timeline.txt ]; then

echo -e "current entries added at: " $(date)  "\n\n $grab  \n\n\n\n" >> timeline.txt

else

echo -e "current entries added at: " $(date)  "\n\n $grab  \n\n\n\n" > timeline.txt

fi

echo -e  "\n\n ~~~ Twitter public timeline log updated & added to 'timeline.txt' at: " $(date) " ~~~"

You'll need to chmod a+x this, and make sure 'curl' in installed! I just thought it would be fun to use, as I've recently started to learn a little regex (regular expressions) and 'sed' (stream editor - Google it!). I'm gonna add a crontab entry to poll the timeline every x minutes.

Have fun!

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.