-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
56 lines (47 loc) · 1.37 KB
/
index.js
File metadata and controls
56 lines (47 loc) · 1.37 KB
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
52
53
54
55
56
var fs = require('fs');
const express = require('express');
const axios = require('axios')
const cheerio = require('cheerio');
const app = express();
const PORT = process.env.port || 3000;
const website = '';
let content = [];
let NumberVal = 200;
const getVV = async _ => {
setTimeout(async () => {
console.log(NumberVal);
const res = await axios(website, {
headers: {
Cookie: ''
}
})
const $ = cheerio.load(res.data);
$('.form-group', res.data).each(function () {
const title = $(this).text().trim();
const url = $(this).find('input').attr('value');
if(url != '' && url != undefined) {
content.push({
[title]: url
});
let fileData = JSON.stringify(content)
console.log('saving');
fs.writeFile("JsonData.txt", fileData, function(err) {
if (err) {
console.log(err);
}
});
}
app.get('/', (req, res) => {
res.json(content);
});
});
NumberVal += 1;
if(NumberVal < 5001) {
getVV()
}
}, 5000)
}
getVV()
app.listen(PORT, () => {
console.log(`server is running on PORT:${PORT}`);
});