-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow-parse.js
29 lines (27 loc) · 1.06 KB
/
show-parse.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
const request = require('request-promise');
const $ = require('cheerio');
const showParse = function(url) {
return request(url)
.then(function(html) {
let show = {
'title': $('.bsp-bio-title', html).first().text(),
'venue': $('.bsp-bio-links-top', html).first().children().first().text(),
'venueLocation': $('.bsp-bio-links-top', html).first().children().last().text(),
'synopsis': $('.bsp-bio-text', html).first().text(),
'cover': $('.bsp-bio-image', html).first().children().first().children().first().attr('src')
};
show['genres'] = new Set;
$('.bsp-bio-sub-text', html).each(function(i, elem) {
show['genres'].add($(this).text());
})
$('.bsp-bio-primary-list', html).children().each(function(i, elem) {
const listItems = $(this).text().split(': ');
show[listItems[0].toLowerCase] = listItems[1];
})
return show;
})
.catch(function(err) {
console.log(err);
});
};
module.exports = showParse;