零度Cc 发表于 2020-9-10 22:47:48

用Python制作的铃声下载小工具

直接上代码....
import requests
import os
from bs4 import BeautifulSoup
import time


def get_url(url):
    headers = {
      'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36'
    }
    res = requests.get(url, headers=headers)
    soup = BeautifulSoup(res.text, 'html.parser')
    items = soup.select('div.b-box')
    urls = ['https:' + item['src'] for item in items.select('source')]# 音乐地址
    names = .select('dt.info') for state in n.find('a')]# 音乐名称
    path = '搞怪铃声'
    if not os.path.exists(path):# 设置存放路径
      os.mkdir(path)
    for name, link in zip(names, urls):
      with open(r'{}\{}.mp3'.format(path, name), 'wb') as file:# 写入数据
            res = requests.get(link)
            print(name, '下载成功')
            file.write(res.content)


link = 'https://www.tukuppt.com/yinxiao/zonghe_0_0_0_0_0_0_{}.html'# 目标地址
page = int(input('请输入下载的页数:'))
urls =

for url in urls:
    get_url(url)
    time.sleep(1)# 休息1秒,以免被封
页: [1]
查看完整版本: 用Python制作的铃声下载小工具