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

72 lines
1.4 KiB
Markdown
Raw 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.

# Web 服務測試與除錯指南
## 問題診斷
### 1. 無法看到文章列表
**可能原因**
- Web 服務未啟動
- API 返回空資料
- 前端 JavaScript 錯誤
- 資料庫連線問題
**檢查步驟**
1. **確認 Web 服務是否運行**
```bash
# 檢查服務是否在運行
curl http://localhost:5000/api/articles
```
2. **檢查資料庫中是否有資料**
```bash
python check_db_data.py
```
3. **檢查瀏覽器控制台**
- 按 F12 開啟開發者工具
- 查看 Console 標籤的錯誤訊息
- 查看 Network 標籤,檢查 API 請求是否成功
### 2. 常見錯誤
#### "Access to storage is not allowed from this context"
這是瀏覽器的安全限制,通常不影響功能。如果影響,可以:
- 使用 `http://localhost:5000` 而不是 `file://` 協議
- 檢查瀏覽器是否允許 localStorage
#### API 返回空資料
檢查:
- 資料庫中是否有資料
- 資料庫連線是否正常
- SQL 查詢是否正確
## 快速修復
### 重新啟動 Web 服務
```bash
# 停止現有服務Ctrl+C
# 然後重新啟動
python web_app.py
# 或
python run_crawler.py --web
```
### 檢查 API 是否正常
在瀏覽器中訪問:
- http://localhost:5000/api/articles
- http://localhost:5000/api/statistics
應該看到 JSON 格式的資料。
### 檢查資料庫
```bash
python check_db_data.py
```
應該顯示資料庫中的文章數量。