python更多源码/资料/解答/教程等 点击此处跳转文末名片免费获取
解释器: python 3.8
编辑器: pycharm 2022.3
第三方模块:
requests >>> 数据请求
execjs >>> pip install pyexecjs
内置模块(无需安装):
模块安装:
win + R 输入cmd 输入安装命令 pip install 模块名 (如果你觉得安装速度比较慢, 你可以切换国内镜像源)
什么是逆向?
https://music.163.com/weapi/song/enhance/player/url/v1?csrf_token=40b2ff585aa4532e59f66bf2ff3c3c4b
1. 先去测试一下接口能不能正常请求拿到数据
2. 删参数测试
3. 开始分析参数的生成
a. 找到 加密函数入口 window.asrsea
b. 分析是否为标准的加密 aes rsa des
c. 假设不是标准的加密 是网易云专门实现的一套加密(手扣代码)
4. python调用js代码 实现加密参数的构建 以及请求的发送
'''
遇到问题没人解答?小编创建了一个Python学习交流QQ群:926207505
寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书!
'''
import requests
import execjs
f = open('demo.js').read()
ctx = execjs.compile(f)
headers = {
'Cookie': 'NMTID=00OCF57eMw7gjtHrkGxqZ7siinxV-IAAAGK1so-IQ; _ntes_nnid=26c70b0143c8e23610c54ff11079e1b2,1695820693625; _ntes_nuid=26c70b0143c8e23610c54ff11079e1b2; WEVNSM=1.0.0; WNMCID=hjvrqg.1695820693938.01.0; WM_TID=5HI1Ko6aOmlEVFVVQRKVyPYt4Zl0AfpQ; ntes_utid=tid._.LGEbSC8WPNJAQlVFAAPFlTdItnXEX3qn._.0; sDeviceId=YD-YNCJ3o0UbKBAU1VRBUaAhFmRbg7QtdJU; __snaker__id=Ux0jj3fJmpH6D5Fl; YD00000558929251%3AWM_TID=LyneRZ7oPElFVEVRFQLEzaJs4dymK3j%2B; __remember_me=true; ntes_kaola_ad=1; YD00000558929251%3AWM_NI=K3XHAVs1RKYu%2B8XnyUtpOw5rEkrkNUMtdFT7fROQFH3KALyTH1sduuIFb%2B0r%2BZY7WXja96%2BbAaSquHY24c4nDdmh7mcywoEf2flxd7s%2FLO3lG7KaWHTT748HeDO9Tl3qYzU%3D; YD00000558929251%3AWM_NIKE=9ca17ae2e6ffcda170e2e6eeb4cc7cb792a0dae1748e8e8fb6d44f969b9e87d867b6f1ffa3e96693b6e5b9c42af0fea7c3b92a89ed98a9c45eb1ef9eacdc7fe9e8988ffc5fb8b08198b87a87b5be8ccd5f8facaca7d73da68e81b2c544f1958fadfc608cefbd85f87f8b9aaeccb37ae98697d8d654aabff7d7aa6a83bf9d92f8449beefc84b76688bca389b667a1a7b990c86ef2baa499e73db1f184b0b26885e98582d644988cf9d5bb44a79c81dad768f1af979bd837e2a3; __csrf=40b2ff585aa4532e59f66bf2ff3c3c4b; _iuqxldmzr_=32; WM_NI=T%2FfWtSNjvtGAkooXecvj4sWvbkyf6Tuab7BWwxWzRI3Dfy9KKtHLxya99VezrA4MobslVEKsFwp9yMMNW5u3EyY4O67tvSfO6wRtr99p7vM%2FAAoq2YDMALydvlx6IFYzOUs%3D; WM_NIKE=9ca17ae2e6ffcda170e2e6eeccf95ef294e1a2ef669a868ba7c85b929f9b87d533a3e9b78df74b8cb0a5d7e42af0fea7c3b92a98f1aab8f7598eb6ba95c64ba9b1a1b9e869b6b6fc94d67ea2b5b787b560b7bfaed8c15db5a8999bd143f19caa9abc4189ac88adfb73a3e7f7b7e872b29ffcaeee6ab1b49aa6ca7986a9c0dafc478f9299d6f83987a797d5ce3ef5acbab4e545f6a99e95f133fbb0f997d025839fa192b15388938fadfc70b6b4b8d7cc4e9ba681b6f237e2a3; MUSIC_U=0016948227D9057DB55CACF7EE3BC6E54D557C4B9FFEC4C17923B93826003DBD522B4FA6B555D599D4BC6B0CCF34750B4E3FC645ED0D801C889E6AF1EA5DA4EA50DB331FDC6EE75563659E0676475FB9850401DA82B8BC28C14B7BF05203E0616449D4E2F9F483C7C0D7CC918C70C7DD51DF718B499955ED7CEC959EE76D903C7EF35D3432F3DB041B3FB10EC0C476C014C9CFC5C10EA7CA499E5027795737D198E7F8B98DABB1201E4D9EFCA77B4769CAF563F3030B7986BF873B511FFA6A376D9C8DB915D84535A1B7F4675D2AD4952ACE513F07B1201713F6C43049D059190158ADC84A1516BA6744FE7039811EA6978F537A16A9AB70ADBA37A9B4F157A5C73E143B2654D881381C5713CD2757DB36C3DE6FB88F6BBDB7FE0AC8CAFA1FD54BC65B9D9ACC5E78089DDB58E189FCB3973E4637861EDE12C381286EBFD8F95FCD8347B08A6F9890B31BB572CE9292571FC39E812C97F8BBA3A2BB651E2D38113C; __csrf=e73e77a7342b7f378110fc1c244de309; gdxidpyhxdE=UHX93r7e4gTV2EkbzuMp79%2Fw%2Bm5pUKteGXt5G9PlS2Kt6e17Ids34oUgYhaLbf7li2xpL6O07oS7cv5%2BNZuwDumu4hpdEszL%2FTzN5qszjR1Gi8SaW9Kb8ScH%2FG8blJ7KZXi1iN4uZRfXhuM0pUElLV5XAKZ4psog3JUx%2BwqyjS2Tkx1O%3A1705068638530; JSESSIONID-WYYY=NGXaEmDtw5xDgaOKczM%2FINu%2BGToHjDIlOhS5drpsXelEgFCyUf2cwWMU9O%2FaAGXipHp3FEmtqljGfSHD2vXvH4kWitnSZnd8hoXTRpkJsXFbFxK6t5rcPGC87jCiNd35c7vcEh7cAJJMo1qK3CpbBId7wyM77I5YO1aTZWgauznHNADs%3A1705130177139; playerid=66893040',
'Referer': 'https://music.163.com/',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
}
mid = '2116714805'
result = ctx.call('sdk', mid)
data = {
'params': result['encText'],
'encSecKey': result['encSecKey']
}
url = 'https://music.163.com/weapi/song/enhance/player/url/v1'
response = requests.post(url=url, headers=headers, data=data)
print(response)
print(response.text)
完整源码和视频讲解我都打包好了,直接文末名片自取~
最后感谢你观看我的文章呐~本次航班到这里就结束啦
希望本篇文章有对你带来帮助 ,有学习到一点知识~
躲起来的星星也在努力发光,你也要努力加油(让我们一起努力叭)。
最后,宣传一下呀~更多源码、资料、素材、解答、交流皆点击下方名片获取呀