Toggle navigation
Toggle navigation
This project
Loading...
Sign in
은승우
/
LINEBOT
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
권은령
2019-12-05 21:36:56 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
114891ee11b1c77d91b5db57526daa443a7b791d
114891ee
1 parent
d2f5a5e1
fixing undefined error
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
app.js
app.js
View file @
114891e
...
...
@@ -45,6 +45,8 @@ const client = new line.Client(config);
// about the middleware, please refer to doc
var
songList
=
[];
// list to store music(singer, song, lyric url)
app
.
post
(
'/webhook'
,
line
.
middleware
(
config
),
(
req
,
res
)
=>
{
Promise
...
...
@@ -214,10 +216,10 @@ function handleEvent(event) {
var
$
=
cheerio
.
load
(
html
);
const
$bodyList
=
$
(
'#body-content > div.search_lyrics > div.music-list-wrap.type-lyrics > table > tbody > tr'
);
var
song
List
=
[];
var
song
s
=
[];
$bodyList
.
each
(
function
(
i
,
elem
){
if
(
i
<
20
){
song
List
.
push
({
song
s
.
push
({
singer
:
$
(
this
).
find
(
"td.info"
).
find
(
"a.artist.ellipsis"
).
text
().
trim
(),
song
:
$
(
this
).
find
(
"td.info"
).
find
(
"a.title.ellipsis"
).
text
().
trim
(),
});
...
...
@@ -226,8 +228,8 @@ function handleEvent(event) {
})
var
resultm
=
''
;
for
(
var
i
=
0
;
i
<
songList
.
length
;
i
++
){
if
(
song
List
[
i
].
singer
!=
''
){
resultm
+=
song
List
[
i
].
singer
+
", "
+
songList
[
i
].
song
+
"\n"
;
if
(
song
s
[
i
].
singer
!=
''
){
resultm
+=
song
s
[
i
].
singer
+
", "
+
songs
[
i
].
song
+
"\n"
;
}
}
var
result
=
{
type
:
'text'
,
text
:
resultm
};
...
...
Please
register
or
login
to post a comment