-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
51 lines (30 loc) · 1.07 KB
/
main.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
50
51
const cheerio = require('cheerio')
var rp = require('request-promise');
const url = 'https://julieanns.com/flavors/';
(function() {
var getResponse = function () {
return rp(url).then(function (body) {
const $ = cheerio.load(body);
var flavor = JSON.parse($(".tribe-events-present div.hentry").attr("data-tribejson"));
var name = flavor.title;
var desc = flavor.excerpt;
var desc = desc.replace(RegExp('<[^>]*>', 'g'), '');
var response = {
"version":"1.0",
"response":{
"outputSpeech": {
"type":"PlainText",
"text": "today's flavor is: " + name + ": " + desc
}
}
};
return response;
});
}
exports.handler = function(event, context, callback) {
console.log('test');
getResponse().then(function(response) {
callback(null, response);
})
};
}());