通过QQ音乐接口获取数据+播放源的方法

https://blog.csdn.net/zc_xy/article/details/79015319
反向代理
https://www.cnblogs.com/shengnan-2017/p/9104079.html
1)使用ProxyTable反向代理
获取歌单:
在这个index.js文件里面找到ProxyTable配置


proxyTable: {
      '/': {
        target: 'https://c.y.qq.com/',
        secure: false,
        changeOrigin: true,
        pathRewrite:{
          '^/api' : '/'
        },
        headers: {
          referer: 'https://c.y.qq.com'
        }
      }
    }

recommend.js中


export function getDiscList() {
  const url = '/api/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg'
  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)
  }).catch((error) => {
    console.log(error)
  })
}

2)node
进入build==>webpack.dev.conf.js


    const express = require('express')  
    const axios = require('axios')  
    const app = express()  
    var apiRoutes = express.Router()  
    app.use('/api', apiRoutes)  

    before(app) {  
          app.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://y.qq.com/portal/playlist.html'  
                referer: 'https://y.qq.com/',  
                host: 'c.y.qq.com'  
              },  
              params: req.query  
            }).then((response) => {  
              res.json(response.data)  
            }).catch((e) => {  
              console.log(e)  
            })  
          })  
        },  
export function getDiscList () {  
  const url = '/api/getDiscList'  
  
  const data = Object.assign({}, commonParams, {  
    rnd: Math.random(),  
    picmid: 1,  
    loginUin: 0,  
    hostUin: 0,  
    notice: 0,  
    platform: 'yqq',  
    needNewCode: 0,  
    categoryId: 10000000,  
    sortId: 5,  
    sin: 0,  
    ein: 29,  
    format: 'json'  
  })  
  
  return axios.get(url, {  
    params: data  
  }).then((res) => {  
    return Promise.resolve(res.data)  
  })  
}  

你可能感兴趣的:(通过QQ音乐接口获取数据+播放源的方法)