For some time now, I have been meaning to have a look at Beautiful Soup, a python library designed to make it easy to scrape data from web-sites. Now that I have finally tried it out, I wish I had got to it sooner. It really is very handy and easy to use.
As my first Soup project, I turned to an old Mule favourite: petrol data. The Australian Institute of Petroleum (AIP) publishes retail petrol price data, which it sources in turn from MotorMouth. The price data is spread across individual pages for each state, like this one for Victoria and there are separate pages for unleaded and diesel. It would be nice to pull together all of the data and, since the pages are all laid out in exactly the same way and there is a straightforward naming convention for the urls of each page, this is very easy to do using Beautiful Soup. You can see the results showing average weekly petrol prices for the week ending 18 December in the table below.
With all the data in hand, the obvious questions to ask are: where is the cheapest petrol and where is the most expensive petrol? As you can see in the chart below, Adelaide came in as the cheapest place to fill your tank in late December at 134.9 cent/L, while Broome was the most expensive at 165.9, an impressive 23% mark up over Adelaide.
Top 10 and bottom 10 unleaded petrol prices
(average for the week ending 18 December 2011)
Of course this only gives a snapshot at a point in time: Adelaide may not always offer such good value for money and Broome residents may not always pay such a premium. Unfortunately, I have not been able to find any historical data by town on the AIP website. So I have set my data-scraping routine up to collect the data each week. Some time late this year I will revisit this data to see if any patterns emerge over time.
|NSW||Tweed Heads South||141|
|VIC||Koo Wee Rup||139.5|
Possibly Related Posts (automatically generated):
- Sydney Petrol Prices (29 June 2008)
- Australian Prices Heading South (29 January 2009)
- Update on Sydney Petrol Prices (21 July 2008)
- Digging into GroceryCHOICE (15 August 2008)
Happy New Year, Stubborn!
Lately, you don’t post often, but when you do, you post very interesting stuff.
This is interesting on two accounts: the Soup and the data itself.
Unfortunately, I’m way too old to get into Python (or any other snake, for that matter :), but the petrol info is interesting.
Say, this might be a wild guess, but I’d guess in Tasmania petrol is cheaper than average. Maybe even cheapest of all.
Switzerland is mostly expensive, but petrol is cheaper than in France or Germany. So the borders have supermarkets on one side and petrol stations on the other.
In contrast, Turkey has the most expensive petrol of any country I have visited. This means that almost everyone uses the buses — and some of the inter-city services run to Swiss precision timing and cleanliness, without being too expensive. I think this – whacking exorbitant taxes on petrol – is a vastly better approach than that taken by China or India, where fuel is actually subsidised!
@Magpie: Happy New Year to you too! 2011 has been a very busy year for me…here’s hoping that 2012 will see fit to allow me to post a little more frequently.
As for Tasmania, for the week ending 18 December, the prices ranged from 144.9 cents/L in Sorrell to 155.5 in Hobart, so in the middle of the spectrum.
@Danny: there’s no doubt that economic incentives can make a big difference.