标签:url amp mod download use blog water 音频 parse
本文的文字及图片来源于网络,仅供学习、交流使用,不具有任何商业用途,如有问题请及时联系我们以作处理。
PS:如有需要Python学习资料的小伙伴可以加点击下方链接自行获取
相关模块pip安装即可
主要是前几天
import requests
url = ‘https://www.tukuppt.com/peiyue/zonghe_0_0_0_0_0_0_1.html‘
headers = {
‘User-Agent‘: ‘Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36‘,
}
response = requests.get(url=url, headers=headers)
import parsel
selector = parsel.Selector(response.text)
urls = selector.css(‘#audio850995 source::attr(src)‘).getall()
titles = selector.css(‘.b-box .info .title::text‘).getall()
data = zip(urls, titles)
for i in data:
mp3_url = ‘https:‘ + i[0]
title = i[1]
def download(url, title):
response = requests.get(url=url, headers=headers)
path = ‘D:\\python\\demo\\熊猫办公素材\\背景音乐\\‘ + title + ‘.mp3‘
with open(path, mode=‘wb‘) as f:
f.write(response.content)
标签:url amp mod download use blog water 音频 parse
原文地址:https://www.cnblogs.com/liuyueqingfeng/p/13777186.html