-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (30 loc) · 988 Bytes
/
Copy pathindex.js
File metadata and controls
36 lines (30 loc) · 988 Bytes
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
const PORT = 8000;
const axios = require('axios');
const cheerio = require('cheerio');
const express = require('express');
const fs = require('fs');
const app = express();
const url = 'https://www.imdb.com/chart/toptv/?ref_=nv_tvv_250';
axios(url).then(res => {
const html = res.data;
const $ = cheerio.load(html);
let article = [];
// $.html() return whole html of url page
$('.titleColumn a', html).each(function () {
console.log($(this).text())
article.push($(this).text())
console.log('---------------')
})
const data = JSON.stringify(article);
fs.writeFile('./config.json', data, function (err) {
if (err) {
console.log('There has been an error saving your configuration data.');
console.log(err.message);
return;
}
console.log('Configuration saved successfully.')
});
})
app.listen(PORT, () => {
console.log(`server is running on port ${PORT}`)
})