이진아

2019년 연재 네이버 웹툰

var express = require('express');
var cheerio = require('cheerio');
var request = require('request');
const axios = require('axios');
//axios 추가 설치된거 확인하기
var router = express.Router();
var mysql = require('mysql');
var client = require('cheerio-httpcli');
......@@ -306,6 +308,38 @@ function getAllToons2() {
allWebtoons2 = allWebtoonList2;
}
allWebtoons3 = new Array();
function getAllToons3(){
allWebtoonList3 = new Array();
//2019년 연재 네이버 웹툰
const naver2019 = 'https://comic.naver.com/webtoon/period.nhn?period=2019';
axios.get(naver2019).then(res => {
if (res.status === 200) {
let naver2019 = [];
const $ = cheerio.load(res.data);
const $movieList = $('#content > div.list_area.daily_img > ul > li');
var tn = 2019;
$movieList.each(function (i) {
naver2019[i] = {
title: $(this).find('dl > dt > a').text(),
img: $(this).find('div > a > img').attr('src'),
index: $(this).find('li > div > a').attr('href'),
year : tn
};
});
const data = naver2019.filter(m => m.title);
allWebtoonList3.push(data);
//console.log(allWebtoonList3)
}
}, (error) => console.log(error));
allWebtoons3 = allWebtoonList3;
}
getAllToons();
//처음 한번 수행
setInterval(getAllToons,5*60*1000);
......@@ -314,10 +348,12 @@ setInterval(getAllToons,5*60*1000);
getAllToons2();
setInterval(getAllToons2,5*60*1000);
getAllToons3();
setInterval(getAllToons3,5*60*1000);
/* GET home page. */
//진아 : list :allWebtoons2 해도 되는지??!!
//진아 : list :allWebtoons2.3 해도 되는지??!!
router.get('/',
function(req,res,next){
if(req.isAuthenticated()){
......@@ -329,6 +365,7 @@ router.get('/',
title: "니툰내툰",
list: allWebtoons
list: allWebtoons2
list: allWebtoons3
});
}
});
......