Deploy and use an LLM-powered public opinion analytics assistant that crawls 26 hot lists from 15 platforms, performs sentiment analysis, topic clustering, and multi-channel alerting
Deploy and use an LLM-powered public opinion analytics assistant that crawls 26 hot lists from 15 platforms, performs sentiment analysis, topic clustering, and multi-channel alerting
triggers
["set up public opinion monitoring system","analyze social media trending topics","deploy sentiment analysis crawler","configure hot topic push notifications","cluster trending news topics","monitor multiple platform hot searches","build opinion analytics dashboard","aggregate cross-platform trending content"]
LLM-Based Intelligent Public Opinion Analytics Assistant
This project is a comprehensive public opinion analytics platform that combines real-time data from 26 hot lists across 15 mainstream platforms (Weibo, Bilibili, Zhihu, Baidu, etc.) with large language model (LLM) analysis capabilities. It provides conversational query interfaces for hot searches, topic clustering, sentiment analysis, and multi-channel push notifications (WeChat, Email, Telegram).
Key Capabilities:
Real-time crawler cluster for 15+ platforms
LLM-powered content analysis (including video content extraction)
Natural language query interface
Topic clustering and sentiment analysis
Multi-channel alert system (Email, WeChat Work, Telegram)
Keyboard shortcuts for crawler control
Installation
Prerequisites
Browser Driver Setup (Required for detail page scraping):
# Check your Chrome/Edge version first
chromedriver /usr/local/bin/
+x /usr/local/bin/chromedriver
chromedriver --version
# Install MySQL 8.0+# Create database and user
mysql -u root -p
CREATE DATABASE hotsearch_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'hotsearch_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON hotsearch_db.* TO 'hotsearch_user'@'localhost';
FLUSH PRIVILEGES;
# MySQL Connection Pool
MYSQL_CONFIG = {
'host': os.getenv('MYSQL_HOST', 'localhost'),
'port': int(os.getenv('MYSQL_PORT', 3306)),
'user': os.getenv('MYSQL_USER'),
'password': os.getenv('MYSQL_PASSWORD'),
'database': os.getenv('MYSQL_DATABASE'),
'charset': 'utf8mb4',
'autocommit': True
}
# Optional: Platform-specific cookies for authenticated access
PLATFORM_COOKIES = {
'weibo': 'your_weibo_cookies', # Optional, for better access'bilibili': 'your_bilibili_cookies'
}
# Concurrent requests
CONCURRENT_REQUESTS = 16
DOWNLOAD_DELAY = 1# User-Agent rotation
USER_AGENTS = [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36'
]
Usage
Starting the System
# Activate virtual environmentsource venv/bin/activate
# Start the main application (web interface + API)
python app.py
# Access web interface at http://localhost:5000
Crawler Management
# Manual crawler test (single platform)
cd hotsearchcrawler
python runspider-test.py
# Start all crawlers (typically triggered via web UI)
python run_spiders.py
Via Web Interface:
Use keyboard shortcuts to start/stop crawlers
View real-time crawling status
Monitor data collection metrics
Natural Language Queries
# Examples of conversational queries via web interface:# "Show me today's top 10 trending topics on Weibo"# "What's trending about AI technology across all platforms?"# "Analyze sentiment for news about electric vehicles"# "Cluster topics related to economic policy"# "Compare hot topics between Bilibili and Zhihu"
# Error: "Message: 'chromedriver' executable needs to be in PATH"# Solution: Verify driver installationwhich chromedriver # Should return path# If not found, reinstall:# 1. Check browser version
google-chrome --version # or microsoft-edge --version# 2. Download exact matching driver version# 3. Place in /usr/local/bin/ and chmod +x# Alternative: Specify driver path in settings
CHROMEDRIVER_PATH=/path/to/chromedriver
Database Connection Errors
# Error: "Can't connect to MySQL server"# Check MySQL service
sudo systemctl status mysql
# Verify credentials
mysql -u hotsearch_user -p -h localhost hotsearch_db
# Check .env file encoding (must be UTF-8 without BOM)
file -I .env # Should show charset=utf-8# Test connection in Pythonimport pymysql
try:
conn = pymysql.connect(
host=os.getenv('MYSQL_HOST'),
user=os.getenv('MYSQL_USER'),
password=os.getenv('MYSQL_PASSWORD'),
database=os.getenv('MYSQL_DATABASE')
)
print("Connection successful")
except Exception as e:
print(f"Error: {e}")
# Error: Request timeout or rate limit# Solution: Implement retry logic and fallbackfrom tenacity import retry, stop_after_attempt, wait_exponential
@retry(stop=stop_after_attempt(3), wait=wait_exponential(min=1, max=10))defcall_llm_with_retry(prompt):
return llm.analyze(prompt)
# Use batch processing for large datasetsfrom hotsearch_analysis_agent.batch_processor import BatchProcessor
processor = BatchProcessor(batch_size=10, delay=2)
results = processor.process_items(news_items, analyze_func)
Memory Issues with Large Datasets
# Error: MemoryError or slow processing# Solution: Use pagination and streamingfrom hotsearch_analysis_agent.db_client import DBClient
db = DBClient()
# Stream results instead of loading all at oncefor batch in db.stream_hot_searches(batch_size=100):
process_batch(batch)
# Process and discard to free memory# Use database aggregation instead of in-memory
aggregated = db.aggregate_by_platform(
start_date='2026-01-01',
end_date='2026-05-01'
)