- Add multi-threaded keyword scheduler for periodic news collection - Create Keyword Manager API for CRUD operations and monitoring - Implement automatic pipeline triggering (RSS → Google → AI → Translation) - Add thread status monitoring and dynamic keyword management - Support priority-based execution and configurable intervals - Add comprehensive scheduler documentation guide - Default keywords: AI, 테크놀로지, 경제, 블록체인 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
import pymongo
|
|
from datetime import datetime
|
|
import json
|
|
|
|
# MongoDB 연결
|
|
client = pymongo.MongoClient("mongodb://localhost:27017/")
|
|
db = client["ai_writer_db"]
|
|
collection = db["articles"]
|
|
|
|
# 최근 생성된 기사 조회
|
|
articles = collection.find().sort("created_at", -1).limit(2)
|
|
|
|
for article in articles:
|
|
print("=" * 80)
|
|
print(f"기사 ID: {article['article_id']}")
|
|
print(f"키워드: {article['keyword']}")
|
|
print(f"제목: {article['title']}")
|
|
print(f"요약: {article['summary']}")
|
|
print(f"처리 시간: {article['processing_time']:.2f}초")
|
|
print(f"생성 시각: {article['created_at']}")
|
|
print(f"파이프라인 단계: {', '.join(article['pipeline_stages'])}")
|
|
print(f"카테고리: {', '.join(article['categories'])}")
|
|
print(f"태그: {', '.join(article['tags'])}")
|
|
print(f"\n내용 (첫 500자):\n{article['content'][:500]}...")
|
|
print("=" * 80)
|
|
print()
|
|
|
|
# 저장된 기사 생성
|
|
with open('generated_article.json', 'w', encoding='utf-8') as f:
|
|
# 최신 기사 하나를 다시 조회
|
|
latest = collection.find_one(sort=[("created_at", -1)])
|
|
if latest:
|
|
# ObjectId를 문자열로 변환
|
|
latest['_id'] = str(latest['_id'])
|
|
# datetime 객체를 문자열로 변환
|
|
latest['created_at'] = latest['created_at'].isoformat()
|
|
json.dump(latest, f, ensure_ascii=False, indent=2)
|
|
print(f"✅ 최신 기사가 generated_article.json 파일로 저장되었습니다.") |