Files
hbr-crawler/啟動Web服務.md
DonaldFang 方士碩 f524713cb6 Initial commit: HBR 文章爬蟲專案
- Scrapy 爬蟲框架,爬取 HBR 繁體中文文章
- Flask Web 應用程式,提供文章查詢介面
- SQL Server 資料庫整合
- 自動化排程與郵件通知功能

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 17:19:56 +08:00

90 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# HBR 爬蟲系統 - Web 服務啟動說明
## 啟動方式
### 方式一:使用 run_crawler.py推薦
```bash
# 啟動 Web 服務
python run_crawler.py --web
```
### 方式二:直接啟動 web_app.py
```bash
# 啟動 Web 服務
python web_app.py
```
## 訪問地址
啟動後,在瀏覽器中訪問:
- **本地訪問**: http://localhost:5000
- **網路訪問**: http://你的IP:5000
## 功能說明
### 1. 統計資訊
- 文章總數
- 付費/免費文章統計
- 分類分布圖表
- 作者統計圖表
### 2. 文章查詢
- 關鍵字搜尋(標題、摘要、內容)
- 分類篩選
- 標籤篩選
- 日期範圍查詢
- 付費狀態篩選
### 3. 文章列表
- 分頁顯示
- 點擊查看文章詳情
- 顯示文章基本資訊(作者、日期、分類、標籤)
### 4. 手動執行爬蟲
- 點擊「執行爬蟲」按鈕
- 自動執行爬蟲並更新資料
## API 端點
### GET /api/articles
取得文章列表
- 參數: page, per_page, category, tag, start_date, end_date, keyword, is_paywalled, language
### GET /api/article/<id>
取得單篇文章詳情
### GET /api/statistics
取得統計資料
### GET /api/categories
取得所有分類列表
### GET /api/tags
取得所有標籤列表
### POST /api/run-crawler
手動觸發爬蟲執行
## 注意事項
1. 確保資料庫連線正常
2. 確保已建立必要的資料表(執行 `python test_db_connection.py`
3. Web 服務預設監聽所有網路介面0.0.0.0),生產環境建議設定防火牆
4. 如需修改埠號,編輯 `web_app.py` 中的 `app.run()` 參數
## 故障排除
### 無法啟動服務
- 確認 Flask 已安裝: `pip install flask`
- 確認資料庫連線正常
- 檢查埠號 5000 是否被占用
### 無法載入資料
- 確認資料庫中有資料
- 檢查資料庫連線設定
- 查看瀏覽器控制台的錯誤訊息