Showing
2 changed files
with
13 additions
and
5 deletions
... | @@ -101,6 +101,8 @@ if(e) console.log('ERROR:', e); | ... | @@ -101,6 +101,8 @@ if(e) console.log('ERROR:', e); |
101 | 101 | ||
102 | */ | 102 | */ |
103 | 103 | ||
104 | +var songList=[]; // list to store music(singer, song, lyric url) | ||
105 | + | ||
104 | 106 | ||
105 | app.post('/webhook', line.middleware(config), (req, res) => { | 107 | app.post('/webhook', line.middleware(config), (req, res) => { |
106 | Promise | 108 | Promise |
... | @@ -125,7 +127,6 @@ function handleEvent(event) | ... | @@ -125,7 +127,6 @@ function handleEvent(event) |
125 | 127 | ||
126 | request(url, function(error, response, html){ | 128 | request(url, function(error, response, html){ |
127 | var $ = cheerio.load(html); | 129 | var $ = cheerio.load(html); |
128 | - var songList=[]; | ||
129 | const $bodyList= $('#body-content > div.newest-list > div > table > tbody > tr'); | 130 | const $bodyList= $('#body-content > div.newest-list > div > table > tbody > tr'); |
130 | 131 | ||
131 | $bodyList.each(function(i, elem){ | 132 | $bodyList.each(function(i, elem){ |
... | @@ -157,6 +158,16 @@ function handleEvent(event) | ... | @@ -157,6 +158,16 @@ function handleEvent(event) |
157 | }); | 158 | }); |
158 | }); | 159 | }); |
159 | } | 160 | } |
161 | + else if(event.message.text.substring(0, 7)=='가사 검색 1') | ||
162 | + { | ||
163 | + return new Promise(function(resolve, reject) | ||
164 | + { | ||
165 | + var result = { type: 'text', text:''}; | ||
166 | + result.text=songList[1].url; | ||
167 | + | ||
168 | + client.replyMessage(event.replyToken, result).then(resolve).catch(reject); | ||
169 | + } | ||
170 | + } | ||
160 | else | 171 | else |
161 | { | 172 | { |
162 | return new Promise(function(resolve, reject) | 173 | return new Promise(function(resolve, reject) | ... | ... |
... | @@ -3,14 +3,11 @@ var request = require('request'); | ... | @@ -3,14 +3,11 @@ var request = require('request'); |
3 | 3 | ||
4 | var url="https://www.genie.co.kr/chart/top200"; | 4 | var url="https://www.genie.co.kr/chart/top200"; |
5 | 5 | ||
6 | - | 6 | +var songList=[]; |
7 | - | ||
8 | request(url, function(error, response, html) | 7 | request(url, function(error, response, html) |
9 | { | 8 | { |
10 | var $ = cheerio.load(html); | 9 | var $ = cheerio.load(html); |
11 | 10 | ||
12 | - var songList=[]; | ||
13 | - | ||
14 | const $bodyList= $('#body-content > div.newest-list > div > table > tbody > tr'); | 11 | const $bodyList= $('#body-content > div.newest-list > div > table > tbody > tr'); |
15 | console.log($bodyList.length); | 12 | console.log($bodyList.length); |
16 | 13 | ... | ... |
-
Please register or login to post a comment