工具
pycharm
目的
采集指定网址下的mp3文件文章来源:https://www.toymoban.com/news/detail-645522.html
代码
import requests
urls = ['https://downsc.chinaz.net/Files/DownLoad/sound1/202303/y1646.mp3',
'https://downsc.chinaz.net/Files/DownLoad/sound1/202303/y1645.mp3',
'https://downsc.chinaz.net/Files/DownLoad/sound1/202303/y1643.mp3',
'https://downsc.chinaz.net/Files/DownLoad/sound1/202303/y1642.mp3',
'https://downsc.chinaz.net/Files/DownLoad/sound1/202303/y1641.mp3']
for i in range(len(urls)):
response = requests.get(urls[i])
# print(response.content)
file_name = urls[i].split('/')[-1]
# print(file_name)
with open(file_name, 'wb') as f:
f.write(response.content)
运行结果
见资源文章来源地址https://www.toymoban.com/news/detail-645522.html
到了这里,关于requests发送请求练习的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!