1.0.0 • Published 8 years ago
music163-crawler v1.0.0
music163-crawler
A little crawler about music163
Install
npm install music163-crawler --save
API
discover()
获取今日推荐歌单
Usage
require("music163-crawler").discover()
.then(res => {
console.log(res);
/*
[
{
id: '493708111', // 歌单id
title: '韩语×付费歌曲精选集',
img: 'http://p4.music.126.net/ehjiXnDSVoIJ_L0cZSqo3A==/109951162808635102.jpg?param=140y140'
},
...
]
*/
}).catch(err => {
...
});
toplist
toplist.getTopList()
获取排行榜分类
Usage
var toplist = require("../lib/crawler/toplist");
toplist.getTopList()
.then(res => {
console.log(res);
/*
[
{
id: '19723756', // 榜单id
title: '云音乐飙升榜',
img: 'http://p3.music.126.net/DrRIg6CrgDfVLEph9SNh7w==/18696095720518497.jpg?param=40y40'
},
...
]
*/
})
.catch(err => {
...
});
toplist.getSongList(id)
获取榜单歌曲列表:
- id:榜单id
Usage
var toplist = require("../lib/crawler/toplist");
toplist.getSongList(id)
.then(res => {
console.log(res);
/*
[
{
id: 462895899, // 音乐id
title: 'Green Light',
album: {
id: 35196822, // 专辑id
name: 'Green Light',
img: 'http://p3.music.126.net/MHIvytC5RXh5Lp2J_3tpaQ==/19017153114022258.jpg'
},
duration: 234039,
artists: [
{
id: 123456, // 歌手id
name: '周杰伦'
},
...
]
},
...
]
*/
})
.catch(err => {
...
});
playlist
playlist.getCategories()
获取歌单分类
Usage
playlist.getCategories()
.then(res => {
console.log(res);
/*
[
{ name: '华语', category: '华语' },
]
*/
})
.catch(err => {
...
})
playlist.getPlayList(limit, offset, order, category)
获取歌单列表:
- limit:限制返回结果个数,默认为 35
- offset: 返回结果偏移量, 默认为 0
- order:排序规则,默认为 "hot",可选值有 "hot" "new"
- category:歌单分类,可填值参照 playlist.getCategories()
Usage
var playlist = require("../lib/crawler/playlist");
playlist.getPlayList(35,35,"hot", "华语")
.then(res => {
console.log(list);
/*
[
{
id: '562605280', //歌单id
title: '2016年我喜欢的歌',
img: 'http://p4.music.126.net/6fDYARt8FtnS3o1ip7_q2w==/1417270493642656.jpg?param=140y140'
},
...
]
*/
})
.catch(err => {
...
});
1.0.0
8 years ago