day07-反调试和周杰伦下载


本节目标:解决无限反调试,下载周杰伦歌曲

https://zz123.com

1.反调试

image-20231204144831334.png

2.搜索列表

image-20231204144210454.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import requests

res = requests.post(
url="https://zz123.com/ajax/",
data={
"act": "search",
"key": "周杰伦",
"lang": "",
"page": 1
}
)
res_dict = res.json()
data_list = res_dict['data']
for item in data_list:
print(item)

3.MP3下载

1
2
3
4
5
6
7
8
9
import requests

res = requests.get(url="https://zz123.com/xplay/?act=songplay&id=vakas", allow_redirects=False)
mp3_url = res.headers['Location']

res = requests.get(url=mp3_url)

with open("晴天.mp3", mode='wb') as f:
f.write(res.content)

4.批量下载

image-20231204144552025.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import requests
import requests

res = requests.post(
url="https://zz123.com/ajax/",
data={
"act": "search",
"key": "周杰伦",
"lang": "",
"page": 1
}
)
res_dict = res.json()
data_list = res_dict['data']
for item in data_list:
mp3_id = item['id']
mp3_name = item['mname']

# 获取真正mp3地址
res = requests.get(
url=f"https://zz123.com/xplay/?act=songplay&id={mp3_id}",
allow_redirects=False
)
real_mp3_url = res.headers['Location']

# 下载
res = requests.get(url=real_mp3_url)
with open(f'{mp3_name}.mp3', mode='wb') as f:
f.write(res.content)


文章作者: Jacky
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Jacky !
  目录