网易云音乐爬取分析

仅供个人学习研究使用 from Crypto.Cipher import AES # 非对称加密 import rsa # 对成加密 import execjs # PyExecJs可以使用Python模拟运行js代码 import base64 import requests first_param = \'{ids: "[1481657185]", br: 128000, csrf_token: ""}\' seconed_param = "010001" third_param = "00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7" four_param = "0CoJUm6Qyw8W8jud" iv = "0102030405060708" # p = execjs.compile(\'\'\'function r(e) { # var t, n, r = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", o = ""; # for (t = 0; e > t; t += 1) # n = Math.random() * r.length, # n = Math.floor(n), # o += r.charAt(n); # return o # }\'\'\') # res = p.call(\'r\', 16) res = "iCTVFitOvyTUbpj2" def AES_encrypt(mes, key): if len(mes) % 16 != 0: mes += (16 - len(mes) % 16) * chr(16 - len(mes) % 16) fun_encrypt = AES.new(key.encode(\'utf-8\'), AES.MODE_CBC, iv.encode(\'utf-8\')) return base64.b64encode(fun_encrypt.encrypt(mes.encode(\'utf-8\'))).decode(\'utf-8\') # return fun_encrypt.encrypt(mes.encode(\'utf-8\')) def RSA_encrypt(mes): pub, priv = rsa.newkeys(131) return rsa.encrypt(mes.encode(\'utf-8\'),pub) def get_params(): params = {} params[\'params\'] = AES_encrypt(AES_encrypt(first_param, four_param), res) # params[\'params\'] = AES_encrypt(first_param, four_param) params[\'encSecKey\'] = \'34947ea467ba7cf43d11ec28e2bb02521a4d2ae21d92526cb1029d2e30d9b5ded84c2ec7c7532520f9ec597dfdea3ac3e74b6a39189c379c3f13626e475ad77daed1e35c5f2de908a7c01e57916b86e0bfa94a6565332437a4b559ad442f2a10d3ce86418bd19988b8c16b7f8805e2f9e6f0a4053abf84b8377eca07108c100c\' print(params) return params base_url = \'https://music.163.com/weapi/song/enhance/player/url\' headers = { \'user-agent\': \'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36\', \'origin\': \'https://music.163.com\' } if __name__ == \'__main__\': data = get_params() response = requests.post(base_url, headers=headers, data=data) print(response.json())

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzpppf.html