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-03 00:27:50 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d6d6291606fefc160d49649826d38eb1232f8e7e
d6d62916
1 parent
e9ef7fe4
update genie music crawling
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
4 deletions
mymusic.js
mymusic.js
View file @
d6d6291
var
cheerio
=
require
(
'cheerio'
);
var
request
=
require
(
'request'
);
var
url
=
"http://www.melcon.com/chart/"
;
var
url
=
"https://www.genie.co.kr/chart/top200"
;
request
(
url
,
function
(
error
,
response
,
html
)
{
var
$
=
cheerio
.
load
(
html
);
var
arr
=
$
(
'.ellipsis rank01'
);
console
.
log
(
arr
[
0
].
children
[
0
].
attribs
.
title
);
var
songList
=
[];
const
$bodyList
=
$
(
'#body-content > div.newest-list > div > table > tbody > tr'
);
console
.
log
(
$bodyList
.
length
);
$bodyList
.
each
(
function
(
i
,
elem
)
{
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
{
return
;
}
})
for
(
var
i
=
0
;
i
<
songList
.
length
;
i
++
)
{
console
.
log
(
songList
[
i
]);
}
var
randnum
=
function
getRandomInt
(
min
,
max
)
{
min
=
Math
.
ceil
(
min
);
max
=
Math
.
floor
(
max
);
return
Math
.
floor
(
Math
.
random
()
*
(
max
-
min
))
+
min
;
//최댓값은 제외, 최솟값은 포함
}(
0
,
20
);
console
.
log
(
randnum
);
var
newUrl
=
songList
[
randnum
].
url
;
})
request
(
newUrl
,
function
(
error
,
response
,
html
)
{
var
$
=
cheerio
.
load
(
html
);
console
.
log
(
songList
[
randnum
].
song
);
console
.
log
(
$
(
'#pLyrics > p'
).
text
());
});
})
\ No newline at end of file
...
...
Please
register
or
login
to post a comment