计算机计算机下载器第二版!
jiyu134
因为一个小小的想法,我决定把之前的下载器再优化一下。
它实现了什么功能呢?
首先它可以实现联网在线获得链接,下载zip,png,jpg,exe格式文件(如果有需要我会再加入别的),在线检测版本这三个功能。
每当我更新了新功能我都会换版本
别看着简单,实际费了我4个小时,尝试了33次才完成的
下面是源码:
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 
 | import requestsimport os
 import sys
 
 def download_file(url, output_path):
 response = requests.get(url)
 if response.status_code == 200:
 with open(output_path, 'wb') as f:
 f.write(response.content)
 print(f"成功下载到:{output_path}")
 else:
 print(f"下载失败:{url}")
 
 def get_file_lines(url):
 response = requests.get(url)
 if response.status_code == 200:
 lines = response.text.splitlines()
 return lines
 else:
 print(f"找不到 {url}")
 return None
 def get_last_line(url):
 response = requests.get(url)
 if response.status_code == 200:
 lines = response.text.splitlines()
 return lines[-1] if lines else None
 else:
 print(f"找不到 {url}")
 return None
 
 
 lines1 = get_file_lines("https://blog.jiyu134.top/input.txt")
 if lines1 is not None:
 lines2 = get_file_lines("https://blog.jiyu134.top/print.txt")
 
 
 last_line = get_last_line("https://blog.jiyu134.top/print.txt")
 
 if last_line is not None:
 if last_line.strip() == "1.1":
 print("版本正确")
 else:
 download_choice = input("版本不正确,需要下载最新版本,请输入Y开始下载,按下其他任意键以无视 \n")
 if download_choice.lower() == 'y':
 output_path = input("请输入保存路径(包括文件名):\n")
 download_url = "https://blog.jiyu134.top/jiyu_download.exe"
 download_file(download_url, output_path)
 sys.exit()
 
 while lines2 is not None:
 user_input = input("请输入16位密钥(按Q退出) \n")
 
 for i, line in enumerate(lines1):
 if line.strip() == user_input.strip():
 result_line = lines2[i]
 
 
 if result_line.endswith(('.zip', '.jpg', '.png', '.exe')):
 download_choice = input(f"找到一个附件({result_line}),是否需要下载?如果需要下载请输入Y,否则按下其他任意键以退出下载,继续识别 \n ")
 if download_choice.lower() == 'y':
 output_path = input("请输入保存路径(包括文件名):\n")
 download_file(result_line, output_path)
 else:
 print("继续输入...")
 else:
 print(f"结果是:{result_line}")
 break
 else:
 print("不存在(404),请重新输入或按Q退出")
 if user_input.lower() == 'q':
 break
 
 if lines2 is None:
 print("找不到结果文件,如果网络没有问题,请报告给管理员")
 break
 else:
 print("找不到比较文件,如果网络没有问题,请报告给管理员")
 
 
 | 
打包我使用的:pyinstaller
还别说,这个用起来还挺简单的
程序下载链接:
目前它还处于空闲状态,也就是目前还不用它
当然如果你想试一试也可以哦~
输入”A””B””C””D””download”来发现吧!
它有一个版本识别功能,但是因为版本基本不变,就不测试了