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 20:38:39 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
593babdb8e437ca1f8db212ac7f8257a6e9e0f42
593babdb
1 parent
8b6ae06c
Update app.js
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
24 deletions
app.js
app.js
View file @
593babd
...
...
@@ -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
result
m
=
''
;
for
(
var
i
=
0
;
i
<
songList
.
length
;
i
++
){
if
(
songList
[
i
].
singer
!=
''
){
result
+=
songList
[
i
].
singer
+
", "
+
songList
[
i
].
song
+
"\n"
;
result
m
+=
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'
)
...
...
Please
register
or
login
to post a comment