未验证 提交 b7388f11 编写于 作者: X xiexupang 提交者: GitHub

Add files via upload

上级 270c9009
import requests
import tkinter as tk
from tkinter import messagebox # import this to fix messagebox error
import time
# 创建主窗口
window = tk.Tk()
window.title('百度文库下载神器')
window.geometry('600x200')
window.geometry('630x200')
# 设置文档链接输入框
tk.Label(window, text='文档链接:').place(x=50, y=30)
var_doc_url = tk.StringVar() # 定义变量,用于输入用户名
entry_doc_url = tk.Entry(window, width=60, textvariable=var_doc_url)
entry_doc_url = tk.Entry(window, width=66, textvariable=var_doc_url)
entry_doc_url.place(x=110, y=30)
# 设置邮箱输入框
tk.Label(window, text='收件邮箱:').place(x=50, y=70)
var_mailbox = tk.StringVar() # 定义变量,用于输入用户名
entry_mailbox = tk.Entry(window, width=60, textvariable=var_mailbox).place(x=110, y=70)
entry_mailbox = tk.Entry(window, width=66, textvariable=var_mailbox).place(x=110, y=70)
# 设置下载进度条
# # 设置下载进度条
tk.Label(window, text='下载进度:').place(x=50, y=110)
download_progress = tk.StringVar() # 定义变量,用于输入用户名
entry_download_progress = tk.Entry(window, width=60, textvariable=download_progress).place(x=110, y=110)
canvas = tk.Canvas(window, width=465, height=22, bg="white")
# 465表示长度,27表示宽度,width=0.4表示粗细
#out_line = canvas.create_rectangle(1.5, 1.5, 465, 23, width=0.4, outline="green")
canvas.place(x=110, y=110)
# 进度显示
def click():
# 填充进度条
fill_line = canvas.create_rectangle(1.5, 1.5, 0, 23, width=0, fill="blue")
x = 500 # 未知变量,可更改
n = 465 / x # 465是矩形填充满的次数
for i in range(x):
n = n + 465 / x
# 以矩形的长度作为变量值更新
canvas.coords(fill_line, (0, 0, n, 60))
window.update()
time.sleep(0.02) # 控制进度条流动的速度
# 清空进度条
fill_line = canvas.create_rectangle(1.5, 1.5, 0, 23, width=0, fill="white")
x = 500 # 未知变量,可更改
n = 465 / x # 465是矩形填充满的次数
for t in range(x):
n = n + 465 / x
# 以矩形的长度作为变量值更新
canvas.coords(fill_line, (0, 0, n, 60))
window.update()
time.sleep(0.00000000002) # 控制进度条流动的速度
# 清空框内的文档链接
def clear_url():
entry_doc_url.delete(0, tk.END)
# 下载文档
def download():
# 获取输入的文档链接和邮箱
doc_url = str(var_doc_url.get())
......@@ -59,12 +91,16 @@ def download():
# 爬虫访问该漏洞,提交携带的数据
response = requests.request("POST", url, data=datas, headers=header)
print('下载成功')
tk.messagebox.showinfo( # 通知型弹窗
title='下载成功', # 窗口标题
message='文档已发送,邮箱可能会对其进行拦截,请注意查看垃圾箱',
)
# 设置清空链接和一键下载按钮
btn_clear = tk.Button(window, text='清空链接', command=clear_url)
btn_clear.place(x=150, y=150)
btn_download = tk.Button(window, text='一键下载', command=download)
btn_download = tk.Button(window, text='一键下载', command=click)
btn_download.place(x=400, y=150)
window.mainloop()
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册