권은령
Showing 1 changed file with 10 additions and 3 deletions
...@@ -200,7 +200,8 @@ function handleEvent(event) { ...@@ -200,7 +200,8 @@ function handleEvent(event) {
200 }; 200 };
201 201
202 request.post(options, function (error, response, body) { 202 request.post(options, function (error, response, body) {
203 - var data=JSON.stringify(body); 203 + var data=JSON.stringify(body);
204 + console.log(data);
204 var text=''; 205 var text='';
205 while(data.indexOf('text\\')!=-1) 206 while(data.indexOf('text\\')!=-1)
206 { 207 {
...@@ -208,6 +209,8 @@ function handleEvent(event) { ...@@ -208,6 +209,8 @@ function handleEvent(event) {
208 text+=data.substring(0,data.indexOf("\\"))+" "; 209 text+=data.substring(0,data.indexOf("\\"))+" ";
209 } 210 }
210 text=text.substring(text.length/10+1,text.length/8+2); 211 text=text.substring(text.length/10+1,text.length/8+2);
212 + text=text.replace(' ','');
213 + text=text.substr(0,text.indexOf(' '));
211 console.log(text); 214 console.log(text);
212 var url="https://www.genie.co.kr/search/searchLyrics?query="+text; 215 var url="https://www.genie.co.kr/search/searchLyrics?query="+text;
213 request(url, function(error, response, html) 216 request(url, function(error, response, html)
...@@ -226,13 +229,17 @@ function handleEvent(event) { ...@@ -226,13 +229,17 @@ function handleEvent(event) {
226 229
227 } 230 }
228 }) 231 })
232 + console.log(songs);
229 var resultm=''; 233 var resultm='';
230 - for(var i=0;i<songList.length;i++){ 234 + for(var i=0;i<songs.length;i++){
231 if(songs[i].singer!=''){ 235 if(songs[i].singer!=''){
232 resultm+=songs[i].singer+", "+songs[i].song+"\n"; 236 resultm+=songs[i].singer+", "+songs[i].song+"\n";
237 + console.log(resultm);
233 } 238 }
234 } 239 }
235 - var result = { type: 'text', text:resultm}; 240 + console.log(resultm);
241 + var result = { type: 'text', text: resultm};
242 + console.log(result);
236 client.replyMessage(event.replyToken,result).then(resolve).catch(reject); 243 client.replyMessage(event.replyToken,result).then(resolve).catch(reject);
237 244
238 }); 245 });
......