윤혜원

다음 웹툰 썸네일이미지 크롤링 성공!

This diff is collapsed. Click to expand it.
...@@ -95,48 +95,46 @@ function getAllToons() { ...@@ -95,48 +95,46 @@ function getAllToons() {
95 allWebtoonList = new Array(); 95 allWebtoonList = new Array();
96 //월요일 다음 웹툰 96 //월요일 다음 웹툰
97 var mon='mon'; 97 var mon='mon';
98 - var daum = `http://webtoon.daum.net/data/pc/webtoon/list_serialized/${mon}?timeStamp=1515819276574`;
99 - var site='daum';
100 var mon_name='MON'; 98 var mon_name='MON';
99 + var daum = `http://webtoon.daum.net/data/pc/webtoon/list_serialized/${mon}?timeStamp=1515819276574`;
100 + var site = 'daum';
101 client.fetch(daum, {}, function (err, $, res, body) { 101 client.fetch(daum, {}, function (err, $, res, body) {
102 var data = JSON.parse(body); 102 var data = JSON.parse(body);
103 var list = data["data"]; 103 var list = data["data"];
104 - console.log(list); 104 + list.forEach(function (item, idx) {
105 - list.forEach(function(item, idx){ 105 + var webtoon_link = 'http://webtoon.daum.net/webtoon/view/' + item.nickname.toString();
106 - var webtoon_link='http://webtoon.daum.net/webtoon/view/'+item.nickname.toString(); 106 + var webtoon = {
107 - var webtoon= {
108 toon_index: item.id, 107 toon_index: item.id,
109 - name : item.title, 108 + name: item.title,
110 - thum_link : webtoon_link, 109 + thum_link: item.pcThumbnailImage.url,
111 - webtoon_link : webtoon_link, 110 + webtoon_link: webtoon_link,
112 - week : mon_name, 111 + week :mon_name,
113 - site : site, 112 + site: site,
114 - latest : 0 113 + latest: 0
115 }; 114 };
116 allWebtoonList.push(webtoon); 115 allWebtoonList.push(webtoon);
117 }); 116 });
117 +
118 }); 118 });
119 +
119 //화요일 다음 웹툰 120 //화요일 다음 웹툰
120 var tue='tue'; 121 var tue='tue';
121 var tue_name='TUE'; 122 var tue_name='TUE';
122 var daum1 = `http://webtoon.daum.net/data/pc/webtoon/list_serialized/${tue}?timeStamp=1515819276574`; 123 var daum1 = `http://webtoon.daum.net/data/pc/webtoon/list_serialized/${tue}?timeStamp=1515819276574`;
123 -
124 client.fetch(daum1, {}, function (err, $, res, body) { 124 client.fetch(daum1, {}, function (err, $, res, body) {
125 var data = JSON.parse(body); 125 var data = JSON.parse(body);
126 var list = data["data"]; 126 var list = data["data"];
127 -
128 list.forEach(function(item, idx){ 127 list.forEach(function(item, idx){
129 var webtoon_link='http://webtoon.daum.net/webtoon/view/'+item.nickname.toString(); 128 var webtoon_link='http://webtoon.daum.net/webtoon/view/'+item.nickname.toString();
130 var webtoon= { 129 var webtoon= {
131 toon_index: item.id, 130 toon_index: item.id,
132 name : item.title, 131 name : item.title,
133 - thum_link : webtoon_link, 132 + thum_link : item.pcThumbnailImage.url,
134 webtoon_link : webtoon_link, 133 webtoon_link : webtoon_link,
135 week : tue_name, 134 week : tue_name,
136 site : site, 135 site : site,
137 latest : 0 136 latest : 0
138 }; 137 };
139 -
140 allWebtoonList.push(webtoon); 138 allWebtoonList.push(webtoon);
141 }); 139 });
142 140
...@@ -157,7 +155,7 @@ function getAllToons() { ...@@ -157,7 +155,7 @@ function getAllToons() {
157 var webtoon= { 155 var webtoon= {
158 toon_index: item.id, 156 toon_index: item.id,
159 name : item.title, 157 name : item.title,
160 - thum_link : webtoon_link, 158 + thum_link : item.pcThumbnailImage.url,
161 webtoon_link : webtoon_link, 159 webtoon_link : webtoon_link,
162 week : wed_name, 160 week : wed_name,
163 site : site, 161 site : site,
...@@ -170,7 +168,7 @@ function getAllToons() { ...@@ -170,7 +168,7 @@ function getAllToons() {
170 168
171 //목요일 다음 웹툰 169 //목요일 다음 웹툰
172 var thu='thu'; 170 var thu='thu';
173 - var daum3 = `http://webtoon.daum.net/data/pc/webtoon/list_serialized/${thu}?timeStamp=1515819276574`; 171 + var daum3 =`http://webtoon.daum.net/data/pc/webtoon/list_serialized/${thu}?timeStamp=1515819276574`;
174 var thu_name='THU'; 172 var thu_name='THU';
175 client.fetch(daum3, {}, function (err, $, res, body) { 173 client.fetch(daum3, {}, function (err, $, res, body) {
176 var data = JSON.parse(body); 174 var data = JSON.parse(body);
...@@ -180,7 +178,7 @@ function getAllToons() { ...@@ -180,7 +178,7 @@ function getAllToons() {
180 var webtoon= { 178 var webtoon= {
181 toon_index: item.id, 179 toon_index: item.id,
182 name : item.title, 180 name : item.title,
183 - thum_link : webtoon_link, 181 + thum_link : item.pcThumbnailImage.url,
184 webtoon_link : webtoon_link, 182 webtoon_link : webtoon_link,
185 week : thu_name, 183 week : thu_name,
186 site : site, 184 site : site,
...@@ -193,18 +191,17 @@ function getAllToons() { ...@@ -193,18 +191,17 @@ function getAllToons() {
193 191
194 //금요일 다음 웹툰 192 //금요일 다음 웹툰
195 var fri='fri'; 193 var fri='fri';
196 - var daum4 = `http://webtoon.daum.net/data/pc/webtoon/list_serialized/${fri}?timeStamp=1515819276574`; 194 + var daum4 =`http://webtoon.daum.net/data/pc/webtoon/list_serialized/${fri}?timeStamp=1515819276574`;
197 var fri_name='FRI'; 195 var fri_name='FRI';
198 client.fetch(daum4, {}, function (err, $, res, body) { 196 client.fetch(daum4, {}, function (err, $, res, body) {
199 var data = JSON.parse(body); 197 var data = JSON.parse(body);
200 - var list1 = data["data"]; 198 + var list = data["data"];
201 - 199 + list.forEach(function(item, idx){
202 - list1.forEach(function(item, idx){
203 var webtoon_link='http://webtoon.daum.net/webtoon/view/'+item.nickname.toString(); 200 var webtoon_link='http://webtoon.daum.net/webtoon/view/'+item.nickname.toString();
204 var webtoon= { 201 var webtoon= {
205 toon_index: item.id, 202 toon_index: item.id,
206 name : item.title, 203 name : item.title,
207 - thum_link : webtoon_link, 204 + thum_link : item.pcThumbnailImage.url,
208 webtoon_link : webtoon_link, 205 webtoon_link : webtoon_link,
209 week : fri_name, 206 week : fri_name,
210 site : site, 207 site : site,
...@@ -217,19 +214,17 @@ function getAllToons() { ...@@ -217,19 +214,17 @@ function getAllToons() {
217 214
218 //토요일 다음 웹툰 215 //토요일 다음 웹툰
219 var sat='sat'; 216 var sat='sat';
220 - var daum5 = `http://webtoon.daum.net/data/pc/webtoon/list_serialized/${sat}?timeStamp=1515819276574`; 217 + var daum5 =`http://webtoon.daum.net/data/pc/webtoon/list_serialized/${sat}?timeStamp=1515819276574`;
221 var sat_name='SAT'; 218 var sat_name='SAT';
222 client.fetch(daum5, {}, function (err, $, res, body) { 219 client.fetch(daum5, {}, function (err, $, res, body) {
223 var data = JSON.parse(body); 220 var data = JSON.parse(body);
224 var list = data["data"]; 221 var list = data["data"];
225 -
226 list.forEach(function(item, idx){ 222 list.forEach(function(item, idx){
227 - //다음 웹툰 아이디, 제목, 요일
228 var webtoon_link='http://webtoon.daum.net/webtoon/view/'+item.nickname.toString(); 223 var webtoon_link='http://webtoon.daum.net/webtoon/view/'+item.nickname.toString();
229 var webtoon= { 224 var webtoon= {
230 toon_index: item.id, 225 toon_index: item.id,
231 name : item.title, 226 name : item.title,
232 - thum_link : webtoon_link, 227 + thum_link : item.pcThumbnailImage.url,
233 webtoon_link : webtoon_link, 228 webtoon_link : webtoon_link,
234 week : sat_name, 229 week : sat_name,
235 site : site, 230 site : site,
...@@ -243,18 +238,17 @@ function getAllToons() { ...@@ -243,18 +238,17 @@ function getAllToons() {
243 //일요일 다음 웹툰 238 //일요일 다음 웹툰
244 var sun='sun'; 239 var sun='sun';
245 var daum6 = `http://webtoon.daum.net/data/pc/webtoon/list_serialized/${sun}?timeStamp=1515819276574`; 240 var daum6 = `http://webtoon.daum.net/data/pc/webtoon/list_serialized/${sun}?timeStamp=1515819276574`;
246 - var sun_name='SUN' 241 + var sun_name='SUN';
247 client.fetch(daum6, {}, function (err, $, res, body) { 242 client.fetch(daum6, {}, function (err, $, res, body) {
248 var data = JSON.parse(body); 243 var data = JSON.parse(body);
249 var list = data["data"]; 244 var list = data["data"];
250 -
251 list.forEach(function(item, idx){ 245 list.forEach(function(item, idx){
252 //다음 웹툰 아이디, 제목, 요일 246 //다음 웹툰 아이디, 제목, 요일
253 var webtoon_link='http://webtoon.daum.net/webtoon/view/'+item.nickname.toString(); 247 var webtoon_link='http://webtoon.daum.net/webtoon/view/'+item.nickname.toString();
254 var webtoon= { 248 var webtoon= {
255 toon_index: item.id, 249 toon_index: item.id,
256 name : item.title, 250 name : item.title,
257 - thum_link : webtoon_link, 251 + thum_link : item.pcThumbnailImage.url,
258 webtoon_link : webtoon_link, 252 webtoon_link : webtoon_link,
259 week : sun_name, 253 week : sun_name,
260 site : site, 254 site : site,
...@@ -262,7 +256,6 @@ function getAllToons() { ...@@ -262,7 +256,6 @@ function getAllToons() {
262 }; 256 };
263 allWebtoonList.push(webtoon); 257 allWebtoonList.push(webtoon);
264 }); 258 });
265 -
266 }); 259 });
267 260
268 var allWeeklyToonsUrl = "http://comic.naver.com/webtoon/weekday.nhn"; 261 var allWeeklyToonsUrl = "http://comic.naver.com/webtoon/weekday.nhn";
...@@ -276,7 +269,7 @@ function getAllToons() { ...@@ -276,7 +269,7 @@ function getAllToons() {
276 var thumb_link = $(this).children().first().children().first().attr('src'); 269 var thumb_link = $(this).children().first().children().first().attr('src');
277 var name = $(this).next().text(); 270 var name = $(this).next().text();
278 var titleid = webtoon_link.split('?')[1].split('&')[0].split('=')[1]; 271 var titleid = webtoon_link.split('?')[1].split('&')[0].split('=')[1];
279 - var site = 'naver' 272 + var site = 'naver';
280 var webtoon= { 273 var webtoon= {
281 toon_index: titleid, 274 toon_index: titleid,
282 name : name, 275 name : name,
......