Monitor for new wine releases using Systembolaget API


For everyone that live in Sweden this is a post about how to alert when new stuff is added to Systembolagets range of products. I will show you how to use a small python script and some bash code to automatically send you an e-mail when new products are discovered. Currently the XML file hosted at Systembolaget is updated every morning at 07:00 AM CET so make sure you schedule it to run just after that.

1. Step one is to set up your server to send e-mail, see my previous post for an example of that on CentOS 7.

2. Head over to systembolaget and their API page here, and get the link to their XML product file which is called “Sortimentsfilen”. This is what we are fetching and it is already included in the bash script, but it can be good to know where you find it.

3. Create the folder “systembolaget” in your root directory. Or whatever directory you will be running the script from. On my test server I just used the root user. Place the python and bash script there.

4. Now time for some python. This is the code:

What it does is that it will read the file called “/root/systembolaget/sortiment.xml” and look for keywords as defined in the variable “names”. When something is found it will check if this is already something I know of and if not print it to screen. That is it. In my example I monitor for Dal Forno and Roccolo Grassi wines.

5. Now it is time for the bash script that actually does the work:

This is the script that you can crontab. Make sure you change the row where it says “” so that you get it sent to a proper email address. You can also change “WINE DISCOVERED!” to whatever you want, that will be the subject of the e-mail.

Leave a Reply

Your email address will not be published. Required fields are marked *