Skip to content

wuzy361/HNMailer

Repository files navigation

HNMailer - Hacker News AI Digest & Email Reporter

🇨🇳 中文文档

A Python crawler for Hacker News with AI-powered analysis and automated email delivery.

🚀 Features

  • Web Interface: Modern responsive UI for browsing news and analysis results
  • AI Analysis: Powered by DeepSeek LLM for intelligent news summarization
  • Email Reports: Beautiful HTML email reports with daily digest
  • Parallel Processing: Multi-threaded analysis for faster performance
  • GitHub Actions: Automated daily execution and email delivery
  • Multiple Email Providers: Support for Gmail, QQ Mail, 163 Mail, etc.

📦 Quick Start

Installation

pip install -r requirements.txt

Set Environment Variable

export DEEPSEEK_API_KEY="your_api_key_here"

Run Analysis

python example_llm_usage.py

🌐 Web Interface

Usage

cd web
python run_web.py

Open browser at http://localhost:8080

Features

  • 🎨 Modern responsive UI design
  • 📊 Real-time news and analysis display
  • 🔄 One-click refresh
  • 📱 Mobile-friendly
  • ⚡ Live status updates
  • 🎯 AI-powered insights

API Endpoints

Endpoint Description
GET / Homepage
GET /api/news Get news data
GET /api/analysis Get AI analysis results
POST /api/refresh Refresh data
GET /api/status Get processing status

🤖 LLM Analysis

The project includes an independent LLM analyzer module:

  1. News Analysis: Automatic trend analysis and summarization
  2. Parallel Processing: Multi-threaded for faster performance
  3. Text Summarization: Intelligent content summarization
  4. Translation: Multi-language support
  5. Insights Generation: Deep analysis on specific topics

Usage

from llm_analyzer import LLMAnalyzer
from example_llm_usage import analyze_news_with_llm

# Parallel analysis (recommended)
analysis_results = analyze_news_with_llm(news_data, parallel=True, max_workers=3)

# Direct analyzer usage
analyzer = LLMAnalyzer()
analysis = analyzer.analyze_news(news_data)
summary = analyzer.summarize_text("Long text content")
translation = analyzer.translate_text("Hello World", "Chinese")

📧 GitHub Actions Deployment

Automate daily analysis and email delivery with GitHub Actions.

Setup Steps

  1. Push to GitHub

  2. Configure Repository Secrets

    Go to: Repository → SettingsSecrets and variablesActionsNew repository secret

    Add the following secrets:

    Secret Name Description
    DEEPSEEK_API_KEY DeepSeek API Key (Get here)
    EMAIL_SENDER Sender email address (e.g., xxx@qq.com)
    EMAIL_PASSWORD Email authorization code (not login password)
    EMAIL_RECIPIENTS Recipient emails, comma-separated
  3. Enable GitHub Actions

    Go to: Repository → Actions → Click "I understand my workflows, go ahead and enable them"

  4. Execution

    • Automatic: Runs daily at 00:00 UTC (08:00 Beijing Time)
    • Manual: Actions page → "Daily HN Analysis" → "Run workflow"

Security

  • email_config.ini is in .gitignore and won't be committed
  • Sensitive data is securely stored in GitHub Secrets

⚙️ Configuration

Local Development

Create email_config.ini:

[qq]
smtp_server = smtp.qq.com
smtp_port = 587
sender_email = your_email@qq.com
sender_password = your_authorization_code
recipient_email = recipient1@example.com, recipient2@example.com

[app]
send_news_count = 20
max_workers = 3
max_comments = 30
topn = 100
model_name = deepseek-chat

Priority

  1. Environment Variables (for CI/CD): EMAIL_SENDER, EMAIL_PASSWORD, EMAIL_RECIPIENTS
  2. Config File (for local dev): email_config.ini

📊 Data Structure

Each news item contains:

Field Description
id News ID
rank Ranking position
title News title
url Original link
domain Source domain
score Points
comments Comment count

📝 Email Authorization

QQ Mail

  1. Login → Settings → Account
  2. Enable POP3/SMTP service
  3. Generate authorization code

Gmail

  1. Enable 2-Step Verification
  2. Generate App Password

163 Mail

  1. Settings → POP3/SMTP → Enable
  2. Get authorization code

⚠️ Disclaimer

  • Please respect the website's robots.txt rules
  • Add appropriate delays to avoid server overload
  • This project is for learning and research purposes only

📄 License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published