, , , , , , ,

My friend was chewing a toothpick like some hip gangster, like some grease-haired pretty boy. In actual fact, he was a puny little Belgian, a 27-year-old with a limp. But still he stuck his thumb into his leather belt and curled his lip. What yah doin’, he asked nonchalantly.

‘I am consuming a RSS feed using Python,’ I replied. It was true, I was pulling down the latest entertainment from Yahoo! Firstly, I’d got hold of the celebrated feedparser, installing the package into Python Tools for Visual Studio. This granted me some nice debugging, ensuring the feed was sliced and diced just the way I wanted it.

Then it was time to port the code over to my Raspberry Pi, which has a wireless connection to the RasWIK Kit. Now, every time Yahoo! serves up an article on Justin Bieber a radio signal is sent to the XinoRF development board to turn on a green bulb. Yay! But if, for some God damn reason, the little pop prince is not the subject of the article, then the red bulb triggers. Boo!

Here’s the code…

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# imports
import serial
from time import sleep
import feedparser

# com port and speed
port = '/dev/ttyAMA0'
baud = 9600

# establish a serial connection
ser = serial.Serial(port=port, baudrate=baud)

# wait

# keep going forever and ever
while 1 == 1:

    # get feed
    feed = feedparser.parse('http://sg.entertainment.yahoo.com/rss/')

    #loop through feed
    for i in range(0,len(feed['entries'])):

        #select bulb depending on feed
        if "Bieber" in feed['entries'][i].title:

            # turn on green bulb as Bieber in article

            # turn on red bulb to show our disgust

        # wait

# kill serial port

You can see from the syntax that we are sending wireless messages from the Pi to the XinoRF, instructing the bulbs on or off.

Here’s the print output…


And here’s the fuckin’ green bulb…


Arkwood was dumbfounded, his mouth wide open. ‘What’s the point of that?’ he finally asked.

I told him. It was a POC.

‘POC? What does that stand for? Piece Of Crap?’

‘No,’ I snapped, ‘It stands for Proof Of Concept. You see, I’ve just registered an account with Network Rail data feeds. Next, I plan to monitor the Swansea to Cardiff line. If the train is on time then I set the green bulb. Cancelled, and it’s red. Why get off the sofa if the news is bleak?’

Arkwood thought for a moment, then, spitting out flakes of wood, said, ‘Can you get it to work for Megan Fox?’