Last active
August 29, 2015 14:18
-
-
Save philippkeller/51893d692578f97f94c4 to your computer and use it in GitHub Desktop.
Parse Chiangmai
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var YQL = require("yql"); | |
var weekdays = ["sonntag", "montag", "dienstag", "mittwoch", "donnerstag", "freitag", "samstag"] | |
var d=new Date() | |
var url = "http://www.chiang-mai.ch/take-away-" + weekdays[d.getDay()] + "/" | |
new YQL.exec("select * from html where url='" + url + "' and xpath='//div[@id=\"box_02\"]//text()'", function(response) { | |
var menues = response.query.results; | |
menues = menues.replace(/[\r]*/g, ""); | |
menues = menues.replace(/(\n[ ]*)+/g, "\n"); | |
for (var i = 1; i < 10; i++) { | |
menues = menues.replace(/\n\s*\n/g, '\n'); | |
}; | |
menues = menues.replace(/^\s*\n/gm, "") | |
var s = menues.split('\n').slice(1); // first one is the title | |
for (i=0;i<s.length;i++) { | |
var menu = s[i]; | |
if (menu.length == 0) { | |
continue; | |
} | |
console.log(menu); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment