Archive for category twitter
I just wrote one of the best one-line bash scripts of all time.
ALL TIME!
curl -s -u Frank__Booth:password -d "track=heineken" http://stream.twitter.com/track.xml | grep "/screen_name" | grep -v Frank__Booth | sed -e 's/[^0-9a-zA-Z]//g' | sed -e 's/screenname//g' | xargs -I '{}' curl --basic --user Frank__Booth:password --data status="@{} Heineken? Fuck that shit! PABST BLUE RIBBON" http://twitter.com/statuses/update.xml
Twitter JSON stream parser
So recently I’ve had occasion to parse the Twitter JSON stream, specifically the spritzer stream for data mining purposes. Turns out this is a pretty difficult problem to solve in most languages. So here’s my Alexandrian solution to this particular Gordian knot, in Bash, because that’s just how I roll.
curl -s --basic --user username:password http://stream.twitter.com/spritzer.json | while read line; do echo "${line}" > temp_tweet ; cat temp_tweet | sed -e 's/=\"/\=\\"/g' | sed -e 's/\">/\\">/g' | ./twitterparse.pl; done
This parses the JSON steam and passes each tweet to a perl script which does the actual parsing.
Hey kids: Don’t do this. It’s bad. If you must, use a tool like jsawk.
comments