Turning Internet into waylay sensors using web scraping

by Veselin Pizurica

Belgians love holiday! So we decided to create a sensor that tells you weather there is a holiday in Belgium. For that we used one web site that has a html table of the holidays in Belgium. In order to turn this into a sensor, we used some little help from cheerio library. So, let’s see how does it work?

var url = "http://www.wettelijke-feestdagen.be/";
var currentDate = new Date();
var isHoliday = false;

            "uri": url
        }, function(err, resp, body){
        var $ = cheerio.load(body);
          var dates = [];
              var tds = $(item).find('td');
              var data = tds.eq(1).text().trim().replace("Mei", "May");
              var dateFeest = {
                   title: $(tds.eq(0)).find('a').text().trim(),
                   data: data,
                   date : new Date(data)
              var tmpFlag = currentDate.getDate()  === dateFeest.date.getDate() &&
              currentDate.getMonth() === dateFeest.date.getMonth();
              isHoliday = isHoliday || tmpFlag;
            var value = {
            observedState: isHoliday? "TRUE" : "FALSE",
            rawData :{
              dates: dates
           send(null, value);

Link to the repo