권은령

fixing error...

Showing 1 changed file with 25 additions and 25 deletions
......@@ -121,40 +121,40 @@ function handleEvent(event)
else if(event.message.text.substring(0, 5)=='순위 보기')
{
// music list 출력
return new Promise(function(resolve, reject){
var result = { type: 'text', text:''};
var url="https://www.genie.co.kr/chart/top200";
var url="https://www.genie.co.kr/chart/top200";
request(url, function(error, response, html){
var $ = cheerio.load(html);
var songList=[];
const $bodyList= $('#body-content > div.newest-list > div > table > tbody > tr');
request(url, function(error, response, html){
var $ = cheerio.load(html);
var songList=[];
const $bodyList= $('#body-content > div.newest-list > div > table > tbody > tr');
$bodyList.each(function(i, elem)
$bodyList.each(function(i, elem){
if(i<20)
{
if(i<20)
{
songList.push(
{
singer: $(this).find("td.info").find("a.artist.ellipsis").text().trim(),
song: $(this).find("td.info").find("a.title.ellipsis").text().trim(),
url: 'https://www.genie.co.kr/detail/songInfo?xgnm='+$(this).attr("songid")
});
}
else
songList.push(
{
return;
}
});
singer: $(this).find("td.info").find("a.artist.ellipsis").text().trim(),
song: $(this).find("td.info").find("a.title.ellipsis").text().trim(),
url: 'https://www.genie.co.kr/detail/songInfo?xgnm='+$(this).attr("songid")
});
}
else
{
return;
}
});
});
return new Promise(function(resolve, reject)
{
var result = { type: 'text', text:''};
for(var i=0; i<songList.length; i++)
{
result.text+=i+1 + ". "+ songList[i].singer+" - "+songList[i].song+"\n";
}
console.log(result.text);
});
client.replyMessage(event.replyToken, result).then(resolve).catch(reject);
client.replyMessage(event.replyToken, result).then(resolve).catch(reject);
});
}
else
......