python语言爬虫爬取歌曲程序代码

import requests

song_urls = [
“http://music.163.com/song/media/outer/url?id=25795016.mp3”,
“https://m703.music.126.net/20240915140140/670dfe5c0144991d4cb778d6662fd762/jd-musicrep-privatecloud-audio-public/obj/woHCgMKXw6XCmDjDj8Oj/25248341156/6dae/5c8c/bac0/44dd85d2d2823b02090dd1a0b4dcad20.mp3”,
“http://music.163.com/song/media/outer/url?id=240515.mp3”

]

for index, song_url in enumerate(song_urls):
response = requests.get(song_url, stream=True)
if response.status_code == 200:
with open(f"downloaded_song_{index + 1}.mp3", “wb”) as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
print(f"歌曲 {index + 1} 下载成功!“)
else:
print(f"请求歌曲 {index + 1} 失败,状态码:{response.status_code}”)

python语言爬虫爬取歌曲程序代码_第1张图片

你可能感兴趣的:(python,爬虫,android)