Skip to content

Instantly share code, notes, and snippets.

@philippkeller
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philippkeller/51893d692578f97f94c4 to your computer and use it in GitHub Desktop.
Save philippkeller/51893d692578f97f94c4 to your computer and use it in GitHub Desktop.
Parse Chiangmai
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