Showing
1 changed file
with
38 additions
and
1 deletions
1 | var express = require('express'); | 1 | var express = require('express'); |
2 | var cheerio = require('cheerio'); | 2 | var cheerio = require('cheerio'); |
3 | var request = require('request'); | 3 | var request = require('request'); |
4 | +const axios = require('axios'); | ||
5 | +//axios 추가 설치된거 확인하기 | ||
4 | var router = express.Router(); | 6 | var router = express.Router(); |
5 | var mysql = require('mysql'); | 7 | var mysql = require('mysql'); |
6 | var client = require('cheerio-httpcli'); | 8 | var client = require('cheerio-httpcli'); |
... | @@ -306,6 +308,38 @@ function getAllToons2() { | ... | @@ -306,6 +308,38 @@ function getAllToons2() { |
306 | allWebtoons2 = allWebtoonList2; | 308 | allWebtoons2 = allWebtoonList2; |
307 | } | 309 | } |
308 | 310 | ||
311 | +allWebtoons3 = new Array(); | ||
312 | + | ||
313 | +function getAllToons3(){ | ||
314 | + allWebtoonList3 = new Array(); | ||
315 | + | ||
316 | + //2019년 연재 네이버 웹툰 | ||
317 | + const naver2019 = 'https://comic.naver.com/webtoon/period.nhn?period=2019'; | ||
318 | + | ||
319 | + axios.get(naver2019).then(res => { | ||
320 | + if (res.status === 200) { | ||
321 | + let naver2019 = []; | ||
322 | + const $ = cheerio.load(res.data); | ||
323 | + const $movieList = $('#content > div.list_area.daily_img > ul > li'); | ||
324 | + var tn = 2019; | ||
325 | + $movieList.each(function (i) { | ||
326 | + naver2019[i] = { | ||
327 | + title: $(this).find('dl > dt > a').text(), | ||
328 | + img: $(this).find('div > a > img').attr('src'), | ||
329 | + index: $(this).find('li > div > a').attr('href'), | ||
330 | + year : tn | ||
331 | + }; | ||
332 | + }); | ||
333 | + | ||
334 | + const data = naver2019.filter(m => m.title); | ||
335 | + allWebtoonList3.push(data); | ||
336 | + //console.log(allWebtoonList3) | ||
337 | + } | ||
338 | + }, (error) => console.log(error)); | ||
339 | + | ||
340 | + allWebtoons3 = allWebtoonList3; | ||
341 | + } | ||
342 | + | ||
309 | getAllToons(); | 343 | getAllToons(); |
310 | //처음 한번 수행 | 344 | //처음 한번 수행 |
311 | setInterval(getAllToons,5*60*1000); | 345 | setInterval(getAllToons,5*60*1000); |
... | @@ -314,10 +348,12 @@ setInterval(getAllToons,5*60*1000); | ... | @@ -314,10 +348,12 @@ setInterval(getAllToons,5*60*1000); |
314 | getAllToons2(); | 348 | getAllToons2(); |
315 | setInterval(getAllToons2,5*60*1000); | 349 | setInterval(getAllToons2,5*60*1000); |
316 | 350 | ||
351 | +getAllToons3(); | ||
352 | +setInterval(getAllToons3,5*60*1000); | ||
317 | 353 | ||
318 | /* GET home page. */ | 354 | /* GET home page. */ |
319 | 355 | ||
320 | -//진아 : list :allWebtoons2 해도 되는지??!! | 356 | +//진아 : list :allWebtoons2.3 해도 되는지??!! |
321 | router.get('/', | 357 | router.get('/', |
322 | function(req,res,next){ | 358 | function(req,res,next){ |
323 | if(req.isAuthenticated()){ | 359 | if(req.isAuthenticated()){ |
... | @@ -329,6 +365,7 @@ router.get('/', | ... | @@ -329,6 +365,7 @@ router.get('/', |
329 | title: "니툰내툰", | 365 | title: "니툰내툰", |
330 | list: allWebtoons | 366 | list: allWebtoons |
331 | list: allWebtoons2 | 367 | list: allWebtoons2 |
368 | + list: allWebtoons3 | ||
332 | }); | 369 | }); |
333 | } | 370 | } |
334 | }); | 371 | }); | ... | ... |
-
Please register or login to post a comment