网易云音乐数据抓取

在云音乐页面上执行,因为用到了页面的加密函数。

function enc_ajax (url, reqObj, cb, cbError) {
    var _crsf = window.NEJ_CONF.p_csrf.param;
    var _token = document.cookie.match(new RegExp(window.NEJ_CONF.p_csrf.cookie + '=(\\w+)'))[1];
    reqObj[_crsf] = _token;
    // 构建 url
    url += url.indexOf('?') === -1 ? '?' : '&';
    url += _crsf + '=' + _token;
    var encryptedData = window.asrsea(JSON.stringify(reqObj), "010001","00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7", "0CoJUm6Qyw8W8jud");
    var postData = 'params=' + encodeURIComponent(encryptedData.encText) +
        '&encSecKey=' + encodeURIComponent(encryptedData.encSecKey);
    var xhr = new XMLHttpRequest();
    xhr.open('POST', url);
    xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    xhr.onload = function () {
        cb(JSON.parse(xhr.responseText));
    };
    xhr.onerror = cbError;
    xhr.send(postData);
    return xhr;
}
this.enc_ajax('/weapi/song/detail/', {
    ids: [27584970]
}, function (data) {
    console.info(data);
});
Post your comments here