, , , , , , ,

Arkwood was playing some notes on his melodica. Two notes. Again. And again. Perhaps those two notes were a C# and a G – who knows – all I can tell you is that I wanted to stuff them up his anus.

‘Shut up!’ I screamed, my concentration smashed.

It was time to start programming our Raspberry Pi, and I was keen to do this from the comfort of my desktop PC, in lieu of adding the code to my tiny computer upon the cramped bedroom carpet. Python is the language of Pi. Visual Studio is the mistress. Cue Python Tools for Visual Studio, a version of which you can get for free. Whilst Arkwood played Ace of Spades, I stepped through the installation and created a standard Python Application project. It was time to start cutting some misshaped code.

Given that our top secret mission would involve fudging about with html, my eyes were drawn to Beautiful Soup. Arkwood simply remarked, ‘Mm, delicious,’ between puffs on his keyboard reed, like the pretentious jazz artiste he is. Regardless, I ploughed on, consulting the ever-tangible Scott Hanselman when setting up a virtual environment and installing a Python package. I added BeautifulSoup4 to the dialog, pip the package manager did the rest.


Let’s try debugging something simple:

from urllib.request import urlopen
from bs4 import BeautifulSoup

html = urlopen("http://ojp.nationalrail.co.uk/service/ldbboard/dep/SWA/CDF/To")
soup = BeautifulSoup(html)

Pooh. An exception was thrown in library file sre_parse.py as I debugged the code. You may want to fiddle about with the Debug menu Exceptions option in Visual Studio, to skip Python exceptions at your Perl [sic].

Good. Now we have a nice big steaming bowl of minestrone soup on which to slurp out some pasta html tags. Yes, the bare bones of a Pythonesque reptilian on which to uncoil our Raspberry Pi. What the fuck am I talking about?

Arkwood was now bobbing about in front of me, his misshaped flute emitting a distinctively Moroccan tune. Cross-eyed. Dribbling. As if he was the delirious snake charmer, not I.