-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.js
executable file
·49 lines (37 loc) · 1.27 KB
/
menu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env node
var cheerio = require('cheerio');
var request = require('request');
var charset = require('charset');
var iconv = require('iconv');
var colors = require('colors');
var S = require('string');
var url = 'http://www.dieuduciel.com/en/home.php'
request({url: url, encoding: 'binary'}, function(err, resp, body) {
enc = charset(resp.headers, body);
if (enc != 'utf-8') {
iconv = new iconv.Iconv(enc, 'UTF-8//TRANSLIT//IGNORE');
html = iconv.convert(new Buffer(body, 'binary')).toString('utf-8');
}
if (err)
throw err;
console.log('Dieu du Ciel beer menu'.underline);
console.log();
$ = cheerio.load(body);
$('#Tableau02 .float li a').each(function() {
var name = $(this).attr('name');
var deschtml = $(this).children().html();
// Removed malformed span
deschtml = deschtml.replace(/<span<><\/span<>/g, '');
deschtml = deschtml.replace(/Type:/g, '');
var desc = deschtml.split("<br>").map(function(d){return S(d).trim().s});
var type = desc[1];
var abv = desc[2];
console.log(name.green);
console.log(type + ", " + abv);
console.log();
});
var uphtml = $('#Tableau_en_03 .datemodif').html();
var update = uphtml.split("<br>");
var update_date = update[1];
console.log("Last update: " + update_date);
});