2025-11-27 18:32:24 +08:00
|
|
|
|
@echo off
|
|
|
|
|
|
chcp 65001 >nul
|
|
|
|
|
|
title 微信公众号文章爬虫系统 - Web界面
|
|
|
|
|
|
|
|
|
|
|
|
echo.
|
|
|
|
|
|
echo ===============================================
|
|
|
|
|
|
echo 🚀 微信公众号文章爬虫系统
|
|
|
|
|
|
echo Web界面启动
|
|
|
|
|
|
echo ===============================================
|
|
|
|
|
|
echo.
|
|
|
|
|
|
|
|
|
|
|
|
:: 检查Python是否安装
|
|
|
|
|
|
python --version >nul 2>&1
|
|
|
|
|
|
if errorlevel 1 (
|
|
|
|
|
|
echo ❌ 未检测到Python,正在尝试其他方法...
|
|
|
|
|
|
goto :use_powershell
|
|
|
|
|
|
) else (
|
|
|
|
|
|
echo ✅ 检测到Python环境
|
|
|
|
|
|
goto :use_python
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
:use_python
|
|
|
|
|
|
echo 📱 使用Python启动Web服务器...
|
|
|
|
|
|
echo 🌐 服务地址: http://localhost:8000
|
|
|
|
|
|
echo ⏰ 启动时间: %date% %time%
|
|
|
|
|
|
echo.
|
|
|
|
|
|
echo 💡 提示: 按 Ctrl+C 停止服务器
|
|
|
|
|
|
echo ===============================================
|
|
|
|
|
|
echo.
|
2025-12-02 14:58:52 +08:00
|
|
|
|
echo 🌐 正在打开浏览器...
|
|
|
|
|
|
start http://localhost:8000/frontend.html
|
|
|
|
|
|
echo.
|
2025-11-27 18:32:24 +08:00
|
|
|
|
|
|
|
|
|
|
cd /d "%~dp0"
|
|
|
|
|
|
python -m http.server 8000
|
|
|
|
|
|
goto :end
|
|
|
|
|
|
|
|
|
|
|
|
:use_powershell
|
|
|
|
|
|
echo 📱 使用PowerShell启动Web服务器...
|
|
|
|
|
|
echo 🌐 服务地址: http://localhost:8080
|
|
|
|
|
|
echo ⏰ 启动时间: %date% %time%
|
|
|
|
|
|
echo.
|
|
|
|
|
|
echo 💡 提示: 按 Ctrl+C 停止服务器
|
|
|
|
|
|
echo ===============================================
|
|
|
|
|
|
echo.
|
|
|
|
|
|
|
|
|
|
|
|
cd /d "%~dp0"
|
|
|
|
|
|
powershell -Command "
|
|
|
|
|
|
$listener = New-Object System.Net.HttpListener
|
|
|
|
|
|
$listener.Prefixes.Add('http://localhost:8080/')
|
|
|
|
|
|
$listener.Start()
|
|
|
|
|
|
Write-Host '✅ Web服务器已启动: http://localhost:8080'
|
|
|
|
|
|
Write-Host '🌐 正在打开浏览器...'
|
2025-12-02 14:58:52 +08:00
|
|
|
|
Start-Process 'http://localhost:8080/frontend.html'
|
2025-11-27 18:32:24 +08:00
|
|
|
|
|
|
|
|
|
|
while ($listener.IsListening) {
|
|
|
|
|
|
$context = $listener.GetContext()
|
|
|
|
|
|
$request = $context.Request
|
|
|
|
|
|
$response = $context.Response
|
|
|
|
|
|
|
|
|
|
|
|
$path = $request.Url.LocalPath
|
2025-12-02 14:58:52 +08:00
|
|
|
|
if ($path -eq '/') { $path = '/frontend.html' }
|
2025-11-27 18:32:24 +08:00
|
|
|
|
|
|
|
|
|
|
$filePath = Join-Path (Get-Location) $path.TrimStart('/')
|
|
|
|
|
|
|
|
|
|
|
|
if (Test-Path $filePath) {
|
|
|
|
|
|
$content = [System.IO.File]::ReadAllBytes($filePath)
|
|
|
|
|
|
$response.ContentType = switch ([System.IO.Path]::GetExtension($filePath).ToLower()) {
|
|
|
|
|
|
'.html' { 'text/html; charset=utf-8' }
|
|
|
|
|
|
'.css' { 'text/css; charset=utf-8' }
|
|
|
|
|
|
'.js' { 'application/javascript; charset=utf-8' }
|
|
|
|
|
|
'.json' { 'application/json; charset=utf-8' }
|
|
|
|
|
|
default { 'text/plain; charset=utf-8' }
|
|
|
|
|
|
}
|
|
|
|
|
|
$response.ContentLength64 = $content.Length
|
|
|
|
|
|
$response.OutputStream.Write($content, 0, $content.Length)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$response.StatusCode = 404
|
|
|
|
|
|
$response.StatusDescription = 'Not Found'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$response.OutputStream.Close()
|
|
|
|
|
|
}
|
|
|
|
|
|
"
|
|
|
|
|
|
|
|
|
|
|
|
:end
|
|
|
|
|
|
echo.
|
|
|
|
|
|
echo ===============================================
|
|
|
|
|
|
echo 服务器已停止运行
|
|
|
|
|
|
echo ===============================================
|
|
|
|
|
|
pause
|