In light of current world events, I think it's particularly important to keep up to date with the latest news. One of my favourite sources of news is the excellent BBC News web site. A few months ago, I noticed that they offered a desktop news ticker application. I didn't particularly like the program, but I thought it would be interesting to access its data stream, as the headlines were short and concise, and a wide range of information was available (world news, UK news, sports, weather, business, sci-tech and so on). My initial strategy was to use strings on the ticker executable, but unfortunately that didn't get me any good results. But then I had a flash of inspiration: enter HTTP::Proxy by PerlMonks' own BooK. With just one line of code I was able to set up an HTTP proxy server on my system. I set my proxy in the ticker application to localhost, and bingo, the URL of the ticker data was revealed: http://tickers.bbc.co.uk/tickerdata/story2.dat.

I downloaded this file and was presently surprised by its simple, text based format. No XML, nothing like that. Check out the file yourself to see its simple format. So, I set about creating a Perl script to parse it. It was a bit more difficult than I had expected, but I got it done.

After getting the parsing working, my main aim was to create a program that could download the file, parse it, extract the main world news headlines and send them to my mobile phone as a text message using SMS. This program would then be run via cron. It worked great - and now I can get the latest news when out and about, even when I'm in the cinema. Some might ask why I didn't use WAP, but well, my phone (Nokia 3210) doesn't support it, and I'm not ready to upgrade. Part of the reason for posting this CUFP is that you get the code and can use it for whatever you want (SMS alerts, WAP, Palm, whatever).

So, if this interests you, feel free to check out the parsing code (along with a simple example).

Another reason why I'm posting this "cool use for Perl" is that I want to get some feedback on whether or not it's worth putting this on CPAN as a module. Any comments would be appreciated.


In reply to News alerts using the BBC's news ticker data file by SuperCruncher

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.