wnwnw

sql query추가, 네이버 완결웹툰 allwebtoonlist 배열에 추가하는 부분 수정

......@@ -78,17 +78,23 @@ function getAllToons3(){
const $ = cheerio.load(res.data);
const $toonList = $('#content > div.list_area.daily_img > ul > li');
var tn = 2019;
var week='finished'
$toonList.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
toon_index : $(this).find('li > div > a').attr('href').split('=')[1],
name : $(this).find('dl > dt > a').text(),
thumb_link: $(this).find('div > a > img').attr('src'),
webtoon_link: "http://comic.naver.com"+$(this).find('li > div > a').attr('href'),
week : week,
//year : tn,
site : site,
latest : 0
};
allWebtoonList3.push(naver2019[i]);
});
const data = naver2019.filter(m => m.title);
allWebtoonList3.push(data);
//const data = naver2019.filter(m => m.title);
//allWebtoonList3.push(data);
//console.log(allWebtoonList3)
}
}, (error) => console.log(error));
......@@ -102,17 +108,23 @@ function getAllToons3(){
const $ = cheerio.load(res.data);
const $toonList = $('#content > div.list_area.daily_img > ul > li');
var tn = 2018;
var week='finished'
$toonList.each(function (i) {
naver2018[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
toon_index : $(this).find('li > div > a').attr('href').split('=')[1],
name : $(this).find('dl > dt > a').text(),
thumb_link: $(this).find('div > a > img').attr('src'),
webtoon_link: "http://comic.naver.com"+$(this).find('li > div > a').attr('href'),
week : week,
//year : tn,
site : site,
latest : 0
};
allWebtoonList3.push(naver2018[i]);
});
const data = naver2018.filter(m => m.title);
allWebtoonList3.push(data);
//const data = naver2018.filter(m => m.title);
//allWebtoonList3.push(data);
//console.log(allWebtoonList3)
}
}, (error) => console.log(error));
......@@ -126,17 +138,23 @@ function getAllToons3(){
const $ = cheerio.load(res.data);
const $toonList = $('#content > div.list_area.daily_img > ul > li');
var tn = 2017;
var week='finished'
$toonList.each(function (i) {
naver2017[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
toon_index : $(this).find('li > div > a').attr('href').split('=')[1],
name : $(this).find('dl > dt > a').text(),
thumb_link: $(this).find('div > a > img').attr('src'),
webtoon_link: "http://comic.naver.com"+$(this).find('li > div > a').attr('href'),
week : week,
//year : tn,
site : site,
latest : 0
};
allWebtoonList3.push(naver2017[i]);
});
const data = naver2017.filter(m => m.title);
allWebtoonList3.push(data);
//const data = naver2017.filter(m => m.title);
//allWebtoonList3.push(data);
//console.log(allWebtoonList3)
}
}, (error) => console.log(error));
......@@ -150,21 +168,26 @@ function getAllToons3(){
const $ = cheerio.load(res.data);
const $toonList = $('#content > div.list_area.daily_img > ul > li');
var tn = 2016;
var week='finished'
$toonList.each(function (i) {
naver2016[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
toon_index : $(this).find('li > div > a').attr('href').split('=')[1],
name : $(this).find('dl > dt > a').text(),
thumb_link: $(this).find('div > a > img').attr('src'),
webtoon_link: "http://comic.naver.com"+$(this).find('li > div > a').attr('href'),
week : week,
//year : tn,
site : site,
latest : 0
};
allWebtoonList3.push(naver2016[i]);
});
const data = naver2016.filter(m => m.title);
allWebtoonList3.push(data);
//const data = naver2016.filter(m => m.title);
//allWebtoonList3.push(data);
//console.log(allWebtoonList3)
}
}, (error) => console.log(error));
//2015년 연재 네이버 웹툰
const naver2015 = 'https://comic.naver.com/webtoon/period.nhn?period=2015';
......@@ -174,17 +197,23 @@ function getAllToons3(){
const $ = cheerio.load(res.data);
const $toonList = $('#content > div.list_area.daily_img > ul > li');
var tn = 2015;
var week='finished'
$toonList.each(function (i) {
naver2015[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
toon_index : $(this).find('li > div > a').attr('href').split('=')[1],
name : $(this).find('dl > dt > a').text(),
thumb_link: $(this).find('div > a > img').attr('src'),
webtoon_link: "http://comic.naver.com"+$(this).find('li > div > a').attr('href'),
week : week,
//year : tn,
site : site,
latest : 0
};
allWebtoonList3.push(naver2015[i]);
});
const data = naver2015.filter(m => m.title);
allWebtoonList3.push(data);
//const data = naver2015.filter(m => m.title);
//allWebtoonList3.push(data);
//console.log(allWebtoonList3)
}
}, (error) => console.log(error));
......@@ -197,17 +226,23 @@ function getAllToons3(){
const $ = cheerio.load(res.data);
const $toonList = $('#content > div.list_area.daily_img > ul > li');
var tn = 2014;
var week='finished'
$toonList.each(function (i) {
naver2014[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
toon_index : $(this).find('li > div > a').attr('href').split('=')[1],
name : $(this).find('dl > dt > a').text(),
thumb_link: $(this).find('div > a > img').attr('src'),
webtoon_link: "http://comic.naver.com"+$(this).find('li > div > a').attr('href'),
week : week,
//year : tn,
site : site,
latest : 0
};
allWebtoonList3.push(naver2014[i]);
});
const data = naver2014.filter(m => m.title);
allWebtoonList3.push(data);
//const data = naver2014.filter(m => m.title);
//allWebtoonList3.push(data);
//console.log(allWebtoonList3)
}
}, (error) => console.log(error));
......@@ -221,17 +256,23 @@ function getAllToons3(){
const $ = cheerio.load(res.data);
const $toonList = $('#content > div.list_area.daily_img > ul > li');
var tn = 2013;
var week='finished'
$toonList.each(function (i) {
naver2013[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
toon_index : $(this).find('li > div > a').attr('href').split('=')[1],
name : $(this).find('dl > dt > a').text(),
thumb_link: $(this).find('div > a > img').attr('src'),
webtoon_link: "http://comic.naver.com"+$(this).find('li > div > a').attr('href'),
week : week,
//year : tn,
site : site,
latest : 0
};
allWebtoonList3.push(naver2013[i]);
});
const data = naver2013.filter(m => m.title);
allWebtoonList3.push(data);
//const data = naver2013.filter(m => m.title);
//allWebtoonList3.push(data);
//console.log(allWebtoonList3)
}
}, (error) => console.log(error));
......@@ -245,17 +286,23 @@ function getAllToons3(){
const $ = cheerio.load(res.data);
const $toonList = $('#content > div.list_area.daily_img > ul > li');
var tn = 2012;
var week='finished'
$toonList.each(function (i) {
naver2012[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
toon_index : $(this).find('li > div > a').attr('href').split('=')[1],
name : $(this).find('dl > dt > a').text(),
thumb_link: $(this).find('div > a > img').attr('src'),
webtoon_link: "http://comic.naver.com"+$(this).find('li > div > a').attr('href'),
week : week,
//year : tn,
site : site,
latest : 0
};
allWebtoonList3.push(naver2012[i]);
});
const data = naver2012.filter(m => m.title);
allWebtoonList3.push(data);
//const data = naver2012.filter(m => m.title);
//allWebtoonList3.push(data);
//console.log(allWebtoonList3)
}
}, (error) => console.log(error));
......@@ -269,17 +316,23 @@ function getAllToons3(){
const $ = cheerio.load(res.data);
const $toonList = $('#content > div.list_area.daily_img > ul > li');
var tn = 2011;
var week='finished'
$toonList.each(function (i) {
naver2011[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
toon_index : $(this).find('li > div > a').attr('href').split('=')[1],
name : $(this).find('dl > dt > a').text(),
thumb_link: $(this).find('div > a > img').attr('src'),
webtoon_link: "http://comic.naver.com"+$(this).find('li > div > a').attr('href'),
week : week,
//year : tn,
site : site,
latest : 0
};
allWebtoonList3.push(naver2011[i]);
});
const data = naver2011.filter(m => m.title);
allWebtoonList3.push(data);
//const data = naver2011.filter(m => m.title);
//allWebtoonList3.push(data);
//console.log(allWebtoonList3)
}
}, (error) => console.log(error));
......@@ -293,17 +346,23 @@ function getAllToons3(){
const $ = cheerio.load(res.data);
const $toonList = $('#content > div.list_area.daily_img > ul > li');
var tn = 2010;
var week='finished'
$toonList.each(function (i) {
naver2010[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
toon_index : $(this).find('li > div > a').attr('href').split('=')[1],
name : $(this).find('dl > dt > a').text(),
thumb_link: $(this).find('div > a > img').attr('src'),
webtoon_link: "http://comic.naver.com"+$(this).find('li > div > a').attr('href'),
week : week,
//year : tn,
site : site,
latest : 0
};
allWebtoonList3.push(naver2010[i]);
});
const data = naver2010.filter(m => m.title);
allWebtoonList3.push(data);
//const data = naver2010.filter(m => m.title);
//allWebtoonList3.push(data);
//console.log(allWebtoonList3)
}
}, (error) => console.log(error));
......@@ -317,17 +376,23 @@ function getAllToons3(){
const $ = cheerio.load(res.data);
const $toonList = $('#content > div.list_area.daily_img > ul > li');
var tn = 2009;
var week='finished'
$toonList.each(function (i) {
naver2009[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
toon_index : $(this).find('li > div > a').attr('href').split('=')[1],
name : $(this).find('dl > dt > a').text(),
thumb_link: $(this).find('div > a > img').attr('src'),
webtoon_link: "http://comic.naver.com"+$(this).find('li > div > a').attr('href'),
week : week,
//year : tn,
site : site,
latest : 0
};
allWebtoonList3.push(naver2009[i]);
});
const data = naver2009.filter(m => m.title);
allWebtoonList3.push(data);
//const data = naver2009.filter(m => m.title);
//allWebtoonList3.push(data);
//console.log(allWebtoonList3)
}
}, (error) => console.log(error));
......@@ -341,17 +406,23 @@ function getAllToons3(){
const $ = cheerio.load(res.data);
const $toonList = $('#content > div.list_area.daily_img > ul > li');
var tn = 2008;
var week='finished'
$toonList.each(function (i) {
naver2008[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
toon_index : $(this).find('li > div > a').attr('href').split('=')[1],
name : $(this).find('dl > dt > a').text(),
thumb_link: $(this).find('div > a > img').attr('src'),
webtoon_link: "http://comic.naver.com"+$(this).find('li > div > a').attr('href'),
week : week,
//year : tn,
site : site,
latest : 0
};
allWebtoonList3.push(naver2008[i]);
});
const data = naver2008.filter(m => m.title);
allWebtoonList3.push(data);
//const data = naver2008.filter(m => m.title);
//allWebtoonList3.push(data);
//console.log(allWebtoonList3)
}
}, (error) => console.log(error));
......@@ -365,17 +436,23 @@ function getAllToons3(){
const $ = cheerio.load(res.data);
const $toonList = $('#content > div.list_area.daily_img > ul > li');
var tn = 2007;
var week='finished'
$toonList.each(function (i) {
naver2007[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
toon_index : $(this).find('li > div > a').attr('href').split('=')[1],
name : $(this).find('dl > dt > a').text(),
thumb_link: $(this).find('div > a > img').attr('src'),
webtoon_link: "http://comic.naver.com"+$(this).find('li > div > a').attr('href'),
week : week,
//year : tn,
site : site,
latest : 0
};
allWebtoonList3.push(naver2007[i]);
});
const data = naver2007.filter(m => m.title);
allWebtoonList3.push(data);
//const data = naver2007.filter(m => m.title);
//allWebtoonList3.push(data);
//console.log(allWebtoonList3)
}
}, (error) => console.log(error));
......@@ -389,17 +466,23 @@ function getAllToons3(){
const $ = cheerio.load(res.data);
const $toonList = $('#content > div.list_area.daily_img > ul > li');
var tn = 2006;
var week='finished'
$toonList.each(function (i) {
naver2006[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
toon_index : $(this).find('li > div > a').attr('href').split('=')[1],
name : $(this).find('dl > dt > a').text(),
thumb_link: $(this).find('div > a > img').attr('src'),
webtoon_link: "http://comic.naver.com"+$(this).find('li > div > a').attr('href'),
week : week,
//year : tn,
site : site,
latest : 0
};
allWebtoonList3.push(naver2006[i]);
});
const data = naver2006.filter(m => m.title);
allWebtoonList3.push(data);
//const data = naver2006.filter(m => m.title);
//allWebtoonList3.push(data);
//console.log(allWebtoonList3)
}
}, (error) => console.log(error));
......@@ -413,23 +496,44 @@ function getAllToons3(){
const $ = cheerio.load(res.data);
const $toonList = $('#content > div.list_area.daily_img > ul > li');
var tn = 2005;
var week='finished'
$toonList.each(function (i) {
naver2005[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
toon_index : $(this).find('li > div > a').attr('href').split('=')[1],
name : $(this).find('dl > dt > a').text(),
thumb_link: $(this).find('div > a > img').attr('src'),
webtoon_link: "http://comic.naver.com"+$(this).find('li > div > a').attr('href'),
week : week,
//year : tn,
site : site,
latest : 0
};
allWebtoonList3.push(naver2005[i]);
});
const data = naver2005.filter(m => m.title);
allWebtoonList3.push(data);
//const data = naver2005.filter(m => m.title);
//allWebtoonList3.push(data);
//console.log(allWebtoonList3)
}
p.then(function() {
i = 0;
allWebtoonList3.forEach(function (webtoon) {
var sql= "INSERT INTO `toon` (toon_index, name, thum_link, webtoon_link, week, site, latest) VALUES(?) ON DUPLICATE KEY UPDATE latest=latest";
var values=[webtoon.toon_index, webtoon.name, webtoon.thum_link, webtoon.webtoon_link,webtoon.week, webtoon.site, webtoon.latest];
connection.query(sql,[values],function(err,result){
if (err) {
console.log("웹툰 DB 에러 : " + err);
} else {
// console.log("웹툰 DB처리 완료!");
}
});
//});
})
}, (error) => console.log(error));
allWebtoons3 = allWebtoonList3;
}
})
}
......