Script to convert Twitter RSS feeds into text

[Update Nov 2012: URLs such as http://twitter.com/statuses/user_timeline/759251.rss do not work anymore, but you can get a Twitter timeline RSS feed by using http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=xxxxx, where xxxxx is the screen name such as cnxsoft]

We needed to convert Twitter RSS feeds to UTF-16 text for displaying them into a digital signage (That did not support RSS feed directly).  This digital signage supports regular http download, .e.g every 5 minutes.

Here’s the script (called with crontab) we used for CNN News Twitter RSS feed.

#!/bin/sh

# CNN Twitter
wget http://twitter.com/statuses/user_timeline/759251.rss
sleep 10
cat 759251.rss | grep title | sed s/\<title\>// | sed s/\<\\/title\>// > cnn.txt
rm 759251.rss
iconv -f utf-8 -t UCS-2LE cnn.txt > cnn-utf16.txt
cp cnn-utf16.txt /var/www/html/livepics/cnn.txt

The resulting text file looks like:

Twitter / CNN
CNN: BREAKING NEWS: Military: Last U.S. brigade combat team leaves Iraq; 56,000 troops remain. Fifty-thousand set to stay past August 31.
CNN: NY Gov. David Paterson discusses Islamic cultural center debate tonight at 9ET on &#8216;Larry King Live.&#8217; http://on.cnn.com/a7gawH

and can be download using a URL, e.g. http://www.myserver.com/livepics/cnn.txt

This works with any Twitter feed including CNXSoft feed :).

Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK Pi 4C Plus
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
0 Comments
Khadas VIM4 SBC