69 lines
1.5 KiB
Batchfile
69 lines
1.5 KiB
Batchfile
@echo off
|
|
setlocal
|
|
chcp 65001 >nul
|
|
set PYTHONIOENCODING=utf-8
|
|
cd /d "%~dp0"
|
|
|
|
echo ============================================
|
|
echo Website Mirror Crawler
|
|
echo Target: http://171.80.3.206:39897/
|
|
echo ============================================
|
|
echo.
|
|
|
|
set "PY="
|
|
|
|
python --version >nul 2>nul
|
|
if not errorlevel 1 (
|
|
set "PY=python"
|
|
goto :found
|
|
)
|
|
|
|
py -3 --version >nul 2>nul
|
|
if not errorlevel 1 (
|
|
set "PY=py -3"
|
|
goto :found
|
|
)
|
|
|
|
python3 --version >nul 2>nul
|
|
if not errorlevel 1 (
|
|
set "PY=python3"
|
|
goto :found
|
|
)
|
|
|
|
if exist "C:\Users\ruigu\AppData\Local\Programs\Python\Python310\python.exe" (
|
|
set "PY=C:\Users\ruigu\AppData\Local\Programs\Python\Python310\python.exe"
|
|
goto :found
|
|
)
|
|
|
|
echo [ERROR] No Python found.
|
|
echo Install Python 3.8+ from https://www.python.org/downloads/
|
|
echo During install, check the box "Add Python to PATH".
|
|
echo Then double-click this file again.
|
|
pause
|
|
exit /b 1
|
|
|
|
:found
|
|
echo Using Python: %PY%
|
|
echo.
|
|
|
|
echo [1/3] Checking dependencies...
|
|
%PY% -c "import requests, bs4" >nul 2>nul
|
|
if errorlevel 1 (
|
|
echo [1/3] Installing requests and beautifulsoup4 ...
|
|
%PY% -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple requests beautifulsoup4
|
|
) else (
|
|
echo [1/3] Dependencies OK
|
|
)
|
|
|
|
echo.
|
|
echo [2/3] Crawling site ... this may take minutes. Do NOT close this window.
|
|
echo.
|
|
%PY% -u mirror.py http://171.80.3.206:39897/
|
|
|
|
echo.
|
|
echo [3/3] Done! Offline copy is here:
|
|
echo %~dp0mirror\171.80.3.206_39897\
|
|
echo Open index.html inside that folder with your browser.
|
|
echo.
|
|
pause
|