如何使用python从网站下载mp3文件
目标:我有一个链接列表,链接到一个mp3文件,我想保存到一个目录 示例:这是我存储在python列表中的链接示例 我试着像这样使用requests模块,但是,这对保存文件不起作用如何使用python从网站下载mp3文件,python,python-3.x,download-manager,Python,Python 3.x,Download Manager,目标:我有一个链接列表,链接到一个mp3文件,我想保存到一个目录 示例:这是我存储在python列表中的链接示例 我试着像这样使用requests模块,但是,这对保存文件不起作用 with open('static/'+url[url.rfind('/')+1:],'wb') as saved_file: response = requests.get(mp3_url, stream=True) if not response.ok: print("[-] Response did n
with open('static/'+url[url.rfind('/')+1:],'wb') as saved_file:
response = requests.get(mp3_url, stream=True)
if not response.ok:
print("[-] Response did not return OK.")
for block in response.iter_content(1024):
if not block:
break
saved_file.write(block)
我建议你用硒 然后,对于要下载的每个youtube标题,您将:
- 在这里构造表单代码的url
- 使用此url打开页面
- 找到并单击该页面中的“下载MP3”按钮