python爬虫篇5——万能音乐下载器

这篇博客介绍了一款使用Python和tkinter构建的音乐下载器,通过可视化界面操作,结合爬虫技术,实现音乐的下载。文章提到代码可能有bug,鼓励读者交流反馈。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

采用tkinter可视化GUI编写的界面,感兴趣的自行查找相关资料学习。

python代码:

import asyncio
import os
import re
import time

import threading
import winreg
from tkinter import *
from urllib import parse
import requests
from lxml import etree


# 127万能音乐下载器

class Music:
    def __init__(self):
        self.init_Menu()

    def init_Menu(self):
        self.top = Tk()
        self.top.geometry("400x400")
        self.top.title("Author:xuhao  QQ:916295795  Email:916295795@qq.com")
        self.show_main_frame()

    def show_main_frame(self):
        self.frame = Frame(self.top)
        self.label = Label(self.frame,
                           text='万能音乐下载器V2.0')
        self.label.pack()
        # 设置数据库地址
        self.windowlabel = Label(self.frame,
                                 text='消息栏')
        self.windowlabel.pack()
        self.cwd = StringVar(self.frame)
        self.cwd.set("快输入歌曲信息叭!(*^▽^*)")
        # frame容器
        self.dirfm = Frame(self.frame)
        # 下滑框
        self.dirsb = Scrollbar(self.dirfm)
        self.dirsb.pack(side=RIGHT, fill=Y)
        self.v = StringVar()
        self.main = Listbox(self.dirfm, listvariable=self.v, height=15,
                            width=50, yscrollcommand=self.dirsb.set)
        self.dirsb.config(command=self.main.yview)
        self.main.pack(side=LEFT, fill=BOTH)
        self.dirfm.pack()
        # 装载了StringVar
        self.dirn = Entry(self.frame, width=50,
                          textvariable=self.cwd)
        self.dirn.pack()
        # 又是一个容器
        self.bfm = Frame(self.frame)
        self.getdata_btn = Button(self.bfm, text='查找歌曲',
                                  command=self.getmusicdata,
                                  activeforeground='white',
                                  activebackground='blue')
        self.download_btn = Button(self.bfm, text='下载歌曲',
                                   command=self.selectdownloaddata,
                                   activeforeground='white',
                                   activebackground='blue')
        self.clear = Button(self.bfm, text='清空输入',
                            command=self.clearInput,
                            activeforeground='white',
                            activebackground='green')
        self.openfiledir = Button(self.bfm, text='歌曲位置',
                                  command=self.openfd,
                                  activeforeground='white',
                                  activebackground='green')
        self.quit = Button(self.bfm, text='退出程序',
                           command=self.top.quit,
                           activeforeground='white',
                           activebackground='red')
        self.getdata_btn.pack(side=LEFT)
        self.download_btn.pack(side=LEFT)
        self.cl
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值