은승우

Update app.js

Showing 1 changed file with 15 additions and 24 deletions
......@@ -97,26 +97,20 @@ async function handleEvent(event) {
};
request.post(options, function (error, response, body) {
let jsonResponse = JSON.stringify(JSON.parse(body), null, ' ');
jsonResponse=jsonResponse.toString()
text='';
while(jsonResponse.indexOf('text')!=-1)
var data=JSON.stringify(body);
var text='';
while(data.indexOf('text\\')!=-1)
{
jsonResponse=jsonResponse.substring(jsonResponse.indexOf('text\\')+9);
text+=jsonResponse.substring(0,jsonResponse.indexOf("\\"))+" ";
}
text.replace('\n','');
if(text.length>20)
{
text=text.substring(text.length/6,text.length/4);
data=data.substring(data.indexOf('text\\')+9);
text+=data.substring(0,data.indexOf("\\"))+" ";
}
text=text.substring(text.length/10+1,text.length/8+2);
console.log(text);
var url="https://www.genie.co.kr/search/searchLyrics?query="+ encodeURI(text);
request(url, function(error, response, html){
var url="https://www.genie.co.kr/search/searchLyrics?query="+text;
request(url, function(error, response, html)
{
console.log(url);
var $ = cheerio.load(html);
const $bodyList= $('#body-content > div.search_lyrics > div.music-list-wrap.type-lyrics > table > tbody > tr');
var songList=[];
......@@ -128,20 +122,17 @@ async function handleEvent(event) {
});
}
console.log(songList);
})
var result='';
var resultm='';
for(var i=0;i<songList.length;i++){
if(songList[i].singer!=''){
result+=songList[i].singer+", "+songList[i].song+"\n";
resultm+=songList[i].singer+", "+songList[i].song+"\n";
}
console.log(result);
}
client.replyMessage(event.replyToken,result).then(resolve).catch(reject);
});
});
console.log(resultm);
});
});
}
else if(event.type == 'message' && event.message.type == 'text')
......