@echo off
chcp 65001 >nul
cd /d "%~dp0"

echo ============================================
echo   网站镜像抓取脚本
echo   目标: http://171.80.3.206:39897/
echo ============================================
echo.

where python >nul 2>nul
if errorlevel 1 (
    echo [错误] 没找到 python，请先安装 Python 3.8+
    pause
    exit /b 1
)

echo [1/3] 检查依赖...
python -c "import requests, bs4" >nul 2>nul
if errorlevel 1 (
    echo [1/3] 缺少依赖，正在安装 requests beautifulsoup4 ...
    python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple requests beautifulsoup4
) else (
    echo [1/3] 依赖已就绪
)

echo.
echo [2/3] 开始抓取（会持续几分钟到几十分钟，请勿关闭窗口）...
echo.
python -u mirror.py http://171.80.3.206:39897/

echo.
echo [3/3] 完成！离线站点在 mirror 目录下：
echo   %~dp0mirror\171.80.3.206_39897\
echo 入口文件：用浏览器打开上面的 index.html
echo.
pause
