更新
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
@echo off
|
||||
setlocal EnableExtensions
|
||||
set "PATH=%SystemRoot%\System32;%PATH%"
|
||||
cd /d "%~dp0"
|
||||
|
||||
if exist "%SystemRoot%\System32\chcp.com" (
|
||||
"%SystemRoot%\System32\chcp.com" 65001 >nul 2>&1
|
||||
)
|
||||
|
||||
echo ========================================
|
||||
echo Douyin IM Collector - Setup
|
||||
echo ========================================
|
||||
echo.
|
||||
echo Install dir: %CD%
|
||||
echo.
|
||||
|
||||
set "PY="
|
||||
where python >nul 2>&1 && set "PY=python"
|
||||
where py >nul 2>&1 && set "PY=py -3"
|
||||
|
||||
if not defined PY (
|
||||
echo [ERROR] Python 3.10+ not found.
|
||||
echo Download: https://www.python.org/downloads/
|
||||
echo Check "Add Python to PATH" during install.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [1/4] Checking Python...
|
||||
%PY% -c "import sys; v=sys.version_info; assert v>=(3,10); print(' Python', sys.version.split()[0])"
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Python 3.10+ required
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [2/4] Creating .venv ...
|
||||
if not exist ".venv\Scripts\python.exe" (
|
||||
%PY% -m venv .venv
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Failed to create venv
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
set "VPY=.venv\Scripts\python.exe"
|
||||
|
||||
echo [3/4] Installing Playwright...
|
||||
"%VPY%" -m pip install --upgrade pip -q
|
||||
"%VPY%" -m pip install -r requirements.txt
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] pip install failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [4/4] Downloading Chromium (~130MB)...
|
||||
set "PLAYWRIGHT_BROWSERS_PATH=%~dp0playwright-browsers"
|
||||
if not exist "%PLAYWRIGHT_BROWSERS_PATH%" mkdir "%PLAYWRIGHT_BROWSERS_PATH%"
|
||||
"%VPY%" -m playwright install chromium
|
||||
if errorlevel 1 (
|
||||
echo [WARN] Chromium download failed. Run fix_browser.bat later.
|
||||
)
|
||||
|
||||
echo.
|
||||
echo ========================================
|
||||
echo Setup complete
|
||||
echo ========================================
|
||||
echo.
|
||||
if /i "%~1"=="silent" exit /b 0
|
||||
echo Next: double-click run_collector.bat or 一键采集.bat
|
||||
echo.
|
||||
pause
|
||||
endlocal
|
||||
Reference in New Issue
Block a user