來源:Rainy_K1 發(fā)布時間:2018-11-01 14:43:06 閱讀量:899
最近正在學習做一個web移動音樂播放器,因為不想做數(shù)據庫存放數(shù)據,所以就學著在QQ音樂的接口獲取一些數(shù)據
出現(xiàn)其他數(shù)據正常,但是無法播放的朋友可以試試這個
獲取歌單數(shù)據:
url: https://c.y.qq.com/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg
//songList.js
export function getDiscList() {
const url = '/api/getDiscList'
const data = Object.assign({}, commonParams, {
platform: 'yqq',
hostUin: 0,
sin: 0,
ein: 29,
sortId: 5,
needNewCode: 0,
categoryId: 10000000,
rnd: Math.random(),
format: 'json'
})
return axios.get(url, {
params: data
}).then((res) => {
return Promise.resolve(res.data)
})
}
webpack.dev.conf.js
// 通過axios代理獲取
/**
* 通過axios,從真實的QQ音樂的地址發(fā)送一個http請求,同時修改一個headers,正確響應,
* 并將內容返回到前端界面
* @param {[type]} req [require]
* @param {String} res [response]
* @param {Function} params: req.query [參數(shù)]
* @return {[type]} [description]
*/
apiRoutes.get('/api/getDiscList', function(req, res) {
var url = 'https://c.y.qq.com/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg'
axios.get(url, {
headers: {
referer: 'https://c.y.qq.com/',
host: 'c.y.qq.com'
},
params: req.query
}).then((response) => {
// 將數(shù)據返回給前端
res.json(response.data)
}).catch((e) => {
console.log(e)
})
})
獲取輪播圖數(shù)據:
url: https://c.y.qq.com/musichall/fcgi-bin/fcg_yqqhomepagerecommend.fcg
export function getRecommend() {
const url = 'https://c.y.qq.com/musichall/fcgi-bin/fcg_yqqhomepagerecommend.fcg'
const data = Object.assign({}, commonParams, {
platform: 'h5',
uin: 0,
needNewCode: 1
})
return jsonp(url, data, options)
}
獲取歌詞數(shù)據:
url: https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg
export function getDiscList() {
const url = '/api/getDiscList'
const data = Object.assign({}, commonParams, {
platform: 'yqq',
hostUin: 0,
sin: 0,
ein: 29,
sortId: 5,
needNewCode: 0,
categoryId: 10000000,
rnd: Math.random(),
format: 'jsonp'
})
return axios.get(url, {
params: data
}).then((res) => {
return Promise.resolve(res.data)
})
}
// webpack.dev.conf.js
apiRoutes.get('/api/lyric', function(req, res) {
var url = 'https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg'
axios.get(url, {
headers: {
referer: 'https://c.y.qq.com',
host: 'c.y.qq.com'
},
params: req.query
}).then((response) => {
var ret = response.data
if (typeof ret === 'string') {
var reg = /^\w+\(({[^()]+})\)$/
var matches = ret.match(reg)
if (matches) {
ret = JSON.parse(matches[1])
}
}
res.json(ret)
}).catch((e) => {
console.log(e)
})
})
獲取歌手信息:
url: https://szc.y.qq.com/v8/fcg-bin/v8.fcg
export function getSingerList() {
const url = 'https://c.y.qq.com/v8/fcg-bin/v8.fcg'
const data = Object.assign({}, commonParams, {
channel: 'singer',
page: 'list',
key: 'all_all_all',
pagesize: 100,
pagenum: 1,
hostUin: 0,
needNewCode: 0,
platform: 'yqq',
g_tk: 2001751543
})
return jsonp(url, data, options)
}
獲取歌曲詳情:
url: https://c.y.qq.com/v8/fcg-bin/fcg_v8_singer_track_cp.fcg
export function getSingerDetail(singerId) {
const url = 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_singer_track_cp.fcg'
const data = Object.assign({}, commonParams, {
hostUin: 0,
needNewCode: 0,
order: 'listen',
platform: 'h5page',
begin: 0,
num: 100,
songstatus: 1,
singermid: singerId,
g_tk: 2001751543
})
return jsonp(url, data, options)
}
獲取排行榜數(shù)據(抓取移動端):
url: https://c.y.qq.com/v8/fcg-bin/fcg_myqq_toplist.fcg
獲取歌單歌曲列表:
url: https://c.y.qq.com/qzone/fcg-bin/fcg_ucc_getcdinfo_byids_cp.fcg
獲取榜單詳情(移動端):
url: https://c.y.qq.com/v8/fcg-bin/fcg_v8_toplist_cp.fcg
---------------------
作者:Rainy_K1
來源:CSDN
原文:https://blog.csdn.net/ZC_XY/article/details/79015319
版權聲明:本文為博主原創(chuàng)文章,轉載請附上博文鏈接!