FromJiucaigongshe(jiuyangongshe.com) scrapes A-share market data in real time, and uses Gemini AI to structurally extract stocks, themes, and investment logic, helping users quickly grasp market dynamics.
First Installation
cd {skillDir} && uv sync && uv run playwright install chromium
Environment Requirements
The API Key is stored in {skillDir}/.env. All scraping commands uniformly use the following prefix:
cd {skillDir} && source .env && export GEMINI_API_KEY
Data Acquisition Strategy (Check the Database First, Then Scrape)
Core Principle: Do not scrape the website every time. Prioritize querying the database.
- Default Behavior — First query the database (
data/themes.db), directly usescripts/query_*.pyto query - Conditions That Trigger Scraping(meeting any one is sufficient):
- The user explicitly says "latest"、"scrape it for me"、"update it"、"go check the website"
- In the databasethere is no data for the current day(the query result is empty)
- Determine whether the database has data for the current day:
cd {skillDir} && uv run python -c " import sqlite3; conn = sqlite3.connect('data/themes.db') cur = conn.cursor() cur.execute(\"SELECT COUNT(*), GROUP_CONCAT(DISTINCT source) FROM articles WHERE publish_date = date('now', 'localtime')\") count, sources = cur.fetchone() print(f'今日数据: {count} 条, 来源: {sources or \"无\"}') " - If scraping is needed, then execute the fetch command for the corresponding scenario
Intent Recognition and Task Routing
Based on the user's natural language question, determine which of the following scenarios it belongs to, and then execute the corresponding operation process. Note: The "scrape" step for each scenario is executed only when needed (see the Data Acquisition Strategy above).
Scenario 1: Market Hotspots / Industry Chain Attention
Trigger Words: market hotspots, popular sectors, industry chain, highest attention, what themes are hot right now
Operation Process:
- Scrape the latest industry chain data:
cd {skillDir} && source .env && export GEMINI_API_KEY && uv run python -m a_stock_watcher.cli fetch --source industry_chain - Query industry chain rankings + related stocks:
cd {skillDir} && uv run python scripts/query_industry_chain.py - Reporting Format: List industry chain names, heat markers, core logic, and related stocks by ranking
Scenario 2: Unusual-Moving Sectors
Trigger Words: what unusual movements are there, unusual-moving sectors, limit-up analysis, today's unusual movements, sector unusual movements
Operation Process:
- Scrape the latest unusual movement data:
cd {skillDir} && source .env && export GEMINI_API_KEY && uv run python -m a_stock_watcher.cli fetch --source action - Query unusual-moving sectors (grouped by date):
cd {skillDir} && uv run python scripts/query_action.py - Reporting Format: Group by date, and list each day's unusual-moving sector titles, involved stocks, and analysis text
Scenario 3: Latest Jokes / Market News
Trigger Words: latest jokes, latest market, what's new, take a look at Jiucaigongshe, how is the market, what's been happening recently
Operation Process:
- Pull the latest content from 5 pages:
cd {skillDir} && source .env && export GEMINI_API_KEY && uv run python -m a_stock_watcher.cli fetch --source study_hotNote: This command requires launching the Playwright browser to render each article one by one, which takes about 5-15 minutes. Please inform the user in advance that they will need to wait.
- Query jokes from the past 2 days + theme heat statistics:
cd {skillDir} && uv run python scripts/query_latest.py - Reporting Format:
- First list the article titles, investment logic, and related stocks from the past 2 days
- Finally attach the Top 10 theme heat statistics
- Use natural language to summarize market sentiment and hotspot directions
Scenario 4: Query a specific stock / theme
Trigger words: How is XX stock doing, articles about XX, which stocks are in the XX theme
Procedure(no scraping needed, query the database directly):
cd {skillDir} && uv run python scripts/query_stock.py <股票名称或代码>
Example:
uv run python scripts/query_stock.py 贵州茅台
uv run python scripts/query_stock.py 600519
Scenario 5: View database statistics
Trigger words: database status, how much data, statistics
cd {skillDir} && source .env && export GEMINI_API_KEY && uv run python -m a_stock_watcher.cli stats
Script list
| Script | Purpose | Scraping needed? |
|---|---|---|
scripts/query_industry_chain.py |
Industry chain ranking + related stocks | fetch industry_chain first |
scripts/query_action.py |
Abnormal movement sectors (grouped by date) | fetch action first |
scripts/query_latest.py |
Last 2 days' snippets + theme heat | fetch study_hot first |
scripts/query_stock.py <关键词> |
Query articles by stock name/code | No (query the database directly) |
Database structure
Location:{skillDir}/data/themes.db(SQLite)
| Table name | Key fields | Purpose |
|---|---|---|
articles |
id, source, title, content, publish_date, logic_summary, relevance | Main article table |
stocks |
id, code, name | Stock entities (deduplicated) |
themes |
id, name, category | Theme entities (deduplicated) |
article_stocks |
article_id, stock_id, context, logic | Article↔stock association |
article_themes |
article_id, theme_id | Article↔theme association |
sourceField values:study_hot/industry_chain/actionrelevanceField: 0-10, AI-assessed A-share relevance (<5 has been filtered out and not stored)
Reporting principles
- Data first, opinions after: Present objective data first (titles, stocks, logic), then give a summary
- Sort by heat: Prioritize displaying themes and stocks with high frequency of occurrence
- Time-sensitive: Snippets and abnormal movements emphasize timeliness, while industry chains focus on long-term trends
- Report in Chinese: All output uses Chinese
- Concise and powerful: Avoid large excerpts of the original text; distill the core information
Notes
- Each study_hot scrape takes about 5~15 minutes (Playwright browser rendering + AI parsing), so inform the user in advance to wait
- If the login session has expired (scraping fails), run:
cd {skillDir} && uv run python -m a_stock_watcher.auth - Database query scripts are instant and do not require GEMINI_API_KEY
- Scraping commands must source .env to load environment variables