전세계

기능: 크롤링한 데이터를 data.json으로 저장

node_modules
package-lock.json
data.json
\ No newline at end of file
......
const fs = require('fs');
const express = require('express');
const app = express();
const port = 80;
......@@ -18,6 +19,10 @@ const getHTML = async () => {
getHTML()
.then(html => {
var today = new Date();
var dateInfo = `${today.getFullYear()}/${today.getMonth() + 1}/${today.getDate()}`;
fakerData['date'] = dateInfo;
const $ = cheerio.load(html.data);
//#region LCK 통산 전적
......@@ -141,7 +146,10 @@ getHTML()
return fakerData;
})
.then(res => console.log(res));
.then(res => {
console.log(res)
fs.writeFileSync('data.json', JSON.stringify(res));
});
app.get('/', (req, res) => {
res.send('Express Test');
......