Files
hbr-crawler/check_db_data.py
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

21 lines
781 B
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""檢查資料庫中的資料"""
from hbr_crawler.hbr_crawler.database import get_database_manager
db = get_database_manager()
result = db.execute_query('SELECT COUNT(*) as count FROM articles', database='db_A101')
if result and len(result) > 0:
print(f"資料庫中的文章數量: {result[0]['count']}")
# 顯示最近5筆
recent = db.execute_query('SELECT id, title, url, crawled_at FROM articles ORDER BY crawled_at DESC LIMIT 5', database='db_A101')
if recent:
print("\n最近5筆文章:")
for article in recent:
title = article.get('title', '無標題')
print(f" - {article['id']}: {title[:50]}...")
else:
print("無法查詢資料庫或資料庫中沒有資料")