[Python爬虫] v2.windows93.net
System-Administartor
2026-01-09 08:42:46
0

将这个文件下载到Python脚本相同的目录下

https://v2.windows93.net/files.json?v=2.4.9


PYTHON
1 2 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
#!/usr/bin/env python3
import os
import json
import requests
from urllib.parse 
import urljoin
from pathlib 
import Path
import sys
import time
# 配置参数BASE_URL = "https://v2.windows93.net/"SAVE_DIR = Path("/vol1/1000/Home/w93")JSON_FILE = "files.json"
def load_json():    """加载JSON文件"""   
try:       
with open(JSON_FILE, 'r', encoding='utf-8') as f:           
return json.load(f)   
except FileNotFoundError:        print(f"错误: 找不到文件 {JSON_FILE}")        sys.exit(1)   
except json.JSONDecodeError as e:        print(f"错误: JSON解析失败 - {e}")        sys.exit(1)
def create_directories(data, base_path="", current_path=""):    """递归创建目录结构"""   
if isinstance(data, dict):       
for key, value in data.items():            # 如果是文件(值为0),跳过目录创建           
if value == 0:               
continue                        new_path = os.path.join(current_path, key)            full_path = SAVE_DIR / base_path / new_path                        # 创建目录           
try:                full_path.mkdir(parents=True, exist_ok=True)                print(f"创建目录: {full_path}")           
except Exception as e:                print(f"创建目录失败 {full_path}: {e}")                        # 递归处理子目录            create_directories(value, base_path, new_path)
def download_files(data, base_path="", current_path=""):    """递归下载文件"""   
if isinstance(data, dict):       
for key, value in data.items():            # 如果是文件(值为0)           
if value == 0:                # 构建文件路径                file_relative_path = os.path.join(current_path, key)                file_local_path = SAVE_DIR / base_path / file_relative_path                                # 检查文件是否已存在               
if file_local_path.exists():                    file_size = file_local_path.stat().st_size                    size_str = f"{file_size/1024:.1f}KB"
if file_size < 1024*1024 
else f"{file_size/(1024*1024):1f}MB"                    print(f"文件已存在,跳过: {file_local_path} ({size_str})")                   
continue                                # 构建下载URL(需要加上基础路径前缀,如"c/"或"a/")                file_url = urljoin(BASE_URL, os.path.join(base_path, file_relative_path))                                # 确保父目录存在                file_local_path.parent.mkdir(parents=True, exist_ok=True)                                # 下载文件               
try:                    print(f"下载: {file_url}")                    response = requests.get(file_url, stream=True, timeout=30)                    response.raise_for_status()                                        # 获取文件大小信息                    file_size = int(response.headers.get('content-length', 0))                                        # 保存文件                    downloaded_size = 0                   
with open(file_local_path, 'wb') as f:                       
for chunk in response.iter_content(chunk_size=8192):                           
if chunk:                                f.write(chunk)                                downloaded_size += len(chunk)                                        # 显示文件大小                    size_str = f"{file_size/1024:.1f}KB"
if file_size < 1024*1024 
else f"{file_size/(1024*1024):.1f}MB"                    print(f"  保存到: {file_local_path} ({size_str})")                                        # 添加短暂延迟,避免对服务器造成过大压力                    # time.sleep(0.01)                                   
except requests.RequestException as e:                    print(f"  下载失败 {file_url}: {e}")               
except Exception as e:                    print(f"  保存失败 {file_local_path}: {e}")                        # 递归处理子目录           
else:                new_path = os.path.join(current_path, key)                download_files(value, base_path, new_path)
def main():    print("=" * 60)    print("Windows93 文件下载脚本")    print(f"源URL: {BASE_URL}")    print(f"目标目录: {SAVE_DIR}")    print("=" * 60)        # 确保保存目录存在    SAVE_DIR.mkdir(parents=True, exist_ok=True)    print(f"创建目标目录: {SAVE_DIR}")        # 加载JSON数据    print(f"
加载JSON文件: {JSON_FILE}")    data = load_json()        # 处理每个顶级目录   
for top_dir in data:        print(f"
处理目录: '{top_dir}'")                # 获取该目录的数据        dir_data = data[top_dir]                # 创建目录结构        print(f"创建 '{top_dir}' 目录结构...")        create_directories(dir_data, top_dir)                # 下载文件        print(f"下载 '{top_dir}' 文件...")        download_files(dir_data, top_dir)        print("
" + "=" * 60)    print("下载完成!")    print("=" * 60)
if __name__ == "__main__":    main()

相关内容

热门资讯

[Python爬虫] v2.w... 将这个文件下载到Python脚本相同的目录下https://v2.windows93.net/fil...
【易语言】文件批量改名 这是一款纯绿色的免费软件,能对大批量的文件进行批量更名,使用简单,更名速度快; 提供基本的文件更名(...
HTML 在线工具箱网站主页... 全能工具箱 - 在线工具集合 ...
[易语言]虚拟机检测 [md]```.版本 2.支持库 spec.程序集 虚拟机检测.子程序 检测虚拟机, 逻辑型, 公开...
PHP最新在线聊天系统源码.z... 源码简介PHP最新在线聊天系统源码,支持多人在线同时聊天,注册记录 ip,封禁 ip 功能。觉得好用...
Python MP3批量更名工... [md]# MP3批量更名工具背景:之前下载到了一堆像ap1014_us1846931430_mii...
Python AES128解密... import osfrom Crypto.Cipher import AESfrom Crypto....
Python ida 9.0注... import jsonimport hashlibimport osfrom datetime im...
PHP二维码生成系统源码 源码简介阿宅QR轻量二维码生成系统源码基于PHP编写的二维码在线生成系统。只需点击几下就可以生成您的...
【PHP】校务管理系统 校务管理系统一个基于 PHP + MySQL 的学校综合管理平台,支持学生学籍管理、教员信息管理、成...

免责声明

本站为个人博客,博客所发布的一切破解软件、补丁、注册机和注册信息及软件的文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。

本站所有内容均来自网络,版权争议与本站无关,您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容,如有需要,请去软件官网下载正版。

访问和下载本站内容,说明您已同意上述条款。

本站为非盈利性站点,不贩卖软件,不会收取任何费用,所有内容不作为商业行为。

正在初始化播放器,请稍后


.social-panel-container { position: fixed; right: 0; bottom: 80px; transform: translateX(100%); transition: transform .4s ease-in-out } .social-panel-container.visible { transform: translateX(-10px) } .social-panel { background-color: #fff; border-radius: 16px; box-shadow: 0 16px 31px -17px rgba(0, 31, 97, 0.6); border: 5px solid #001f61; display: flex; flex-direction: column; justify-content: center; align-items: center; font-family: 'Muli'; position: relative; height: 169px; width: 370px; max-width: calc(100% - 10px) } .social-panel button.close-btn { border: 0; color: #97a5ce; cursor: pointer; font-size: 20px; position: absolute; top: 5px; right: 5px } .social-panel button.close-btn:focus { outline: 0 } .social-panel p { background-color: #001f61; border-radius: 0 0 10px 10px; color: #fff; font-size: 14px; line-height: 18px; padding: 2px 17px 6px; position: absolute; top: 0; left: 50%; margin: 0; transform: translateX(-50%); text-align: center; width: 235px } .social-panel p a { color: #ff7500; text-decoration: none } .social-panel h4 { margin: 20px 0; color: #97a5ce; font-family: 'Muli'; font-size: 14px; line-height: 18px; text-transform: uppercase } .social-panel ul { display: flex; list-style-type: none; padding: 0; margin: 0 } .social-panel ul li { margin: 0 10px } .social-panel ul li a { border: 1px solid #dce1f2; border-radius: 50%; color: #001f61; font-size: 20px; display: flex; justify-content: center; align-items: center; height: 50px; width: 50px; text-decoration: none } .social-panel ul li a:hover { border-color: #ff6a00; box-shadow: 0 9px 12px -9px #ff6a00 } .floating-btn { border-radius: 26.5px; background-color: #001f61; border: 1px solid #001f61; box-shadow: 0 16px 22px -17px #03153b; color: #fff; cursor: pointer; font-size: 16px; line-height: 20px; padding: 12px 20px; position: fixed; bottom: 20px; right: 20px; z-index: 999 } .floating-btn:hover { background-color: #fff; color: #001f61 } .floating-btn:focus { outline: 0 } .floating-text { background-color: #001f61; border-radius: 10px 10px 0 0; color: #fff; font-family: 'Muli'; padding: 7px 15px; position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); text-align: center; z-index: 998 } .floating-text a { color: #ff7500; text-decoration: none } /* 确保代码块正确换行 */ .code-block-wrapper pre code { white-space: pre-wrap !important; word-break: break-all !important; word-wrap: break-word !important; } /* Markdown内容样式增强 */ .markdown-content pre { background: #f6f8fa !important; border-radius: 8px !important; padding: 16px !important; overflow-x: auto !important; margin: 1em 0 !important; } .markdown-content code:not(pre code) { background: #f1f3f4 !important; padding: 2px 6px !important; border-radius: 4px !important; font-size: 0.9em !important; }

人生倒计时

今天已过去 20 小时
84%
本周已过去 2 天
28%
本月已过去 26 天
86%
今年已过去 8 个月 零 26 天
66%
离春节还有137天4时
62%