Fetch data from the Wenyin Internet announcement extraction service API, support two aggregation modes: by company or by type, and generate Markdown-format posts.
Quick Start
Run scripts/fetch_and_format.py to generate a post with one click:
# 按公司聚合(默认)
python3 scripts/fetch_and_format.py \
--infotype "O_临时公告_董事会决议"
# 按类型聚合
python3 scripts/fetch_and_format.py \
--infotype "O_临时公告_董事会决议" \
--group-by type
Specify Date Range
python3 scripts/fetch_and_format.py
--infotype "O_临时公告_董事会决议"
--start_date 2026-01-14
--end_date 2026-01-16
python3 scripts/fetch_and_format.py
--infotype "O_临时公告_人事变动"
--output post.md
python3 scripts/fetch_and_format.py
--infotype "O_临时公告_董事会决议"
--api_base http://127.0.0.1:8452
**注意**:`--start_date` 和 `--end_date` 不传则默认当天。若查询无数据,脚本不产生任何输出(exit 0)。
## 聚合方式
支持两种发帖路由:
### 1. 按公司聚合(默认)
按公司维度聚合公告,适合查看某家公司的所有公告类型。
**特点:**
- 每家公司展示全部公告
- 包含公司公告数量排行榜
- 自动生成洞察分析
- 适合查看市场热点公司
**使用示例:**
```bash
python scripts/fetch_and_format.py --infotype "O_临时公告_董事会决议" --group-by company
2. Aggregate by Type
Aggregate by announcement type, suitable for viewing announcements from different companies under the same type.
Features:
- Display announcements categorized by type
- Include type statistics rankings
- Clear hierarchical structure
- Suitable for browsing the overall market situation of a certain type of announcement
Usage Example:
python scripts/fetch_and_format.py --infotype "O_临时公告_董事会决议" --group-by type
Selection Suggestions:
- Few announcements (<30 items) → aggregate by company, convenient for in-depth reading
- Many announcements (>30 items) → aggregate by type, clearer structure
- Focus on a specific type (e.g., all personnel changes) → aggregate by type
Supported Announcement Types
| infotype Parameter Value | Chinese Name |
|---|---|
O_临时公告_董事会决议 |
Board Resolution |
O_临时公告_人事变动 |
Personnel Change |
O_临时公告_设立产业基金 |
Establishment of Industrial Fund |
O_临时公告_与私募基金合作投资 |
Cooperative Investment with Private Equity Fund |
O_临时公告_药品批准 |
Drug Approval |
O_临时公告_应当披露交易 |
Transaction That Should Be Disclosed |
O_临时公告_转债付息 |
Convertible Bond Interest Payment |
O_临时公告_重大资产重组终止 |
Termination of Major Asset Restructuring |
O_临时公告_股东大会通知_议案表 |
Shareholders' Meeting Notice Proposal Table |
O_临时公告_股票交易异常波动 |
Abnormal Fluctuation in Stock Trading |
O_临时公告_股票交易风险提示 |
Stock Trading Risk Warning |
O_临时公告_股东大会召开通知 |
Notice of Convening Shareholders' Meeting |
O_临时公告_用募集资金置换预先投入的自筹资金 |
Replacing Pre-invested Self-raised Funds with Raised Funds |
O_临时公告_变更证券简称 |
Change of Securities Abbreviation |
O_临时公告_召开业绩说明会 |
Convening Performance Briefing |
O_临时公告_可转债到期兑付及摘牌 |
Maturity Redemption and Delisting of Convertible Bonds |
O_临时公告_取消重大资产重组并复牌 |
Cancellation of Major Asset Restructuring and Resumption of Trading |
O_临时公告_变更会计师事务所 |
Change of Accounting Firm |
O_临时公告_公告元信息 |
Announcement Metadata |
O_临时公告_中标候选人公示 |
Winning Bid Candidate Public Notice |
股东大会延期 |
Postponement of Shareholders' Meeting |
股东大会通知 |
Shareholders' Meeting Notice |
推选职工董事或者监事 |
Election of Employee Director or Supervisor |
核心技术人员离职 |
Resignation of Core Technical Personnel |
职工代表大会决议 |
Resolution of Employee Representative Assembly |
优先股股息分派 |
Preferred Stock Dividend Distribution |
取得发明专利证书 |
Obtaining Invention Patent Certificate |
业务资格获批 |
Business Qualification Approval |
Output Format
Generated Markdown post structure (aggregate by company):
- Title — includes number of companies, type, date range, total number of items
- Format:
# 【{公司数}家公司】{类型}公告汇总({开始日期} ~ {结束日期})【共{总条数}条】
- Format:
- 📋 Overview — announcement type, time range, total number of announcements, number of companies involved, data source
- 💰 Overall Investment Analysis(⭐ Core highlights, placed after the overview for quick reading):
- Market Overview Summary
- Investment Focus Points (listed by item)
- Risk Warnings
- 📊 Data Statistics and Insights — Automatically generated insight analysis:
- Most Active Companies (most announcements)
- Market Concentration Analysis
- Announcement Density Alert
- Company Announcement Count Ranking — Top 10 companies and announcement counts (table format)
- 📑 Table of Contents — List of companies sorted by securities code
- Announcement Details Grouped by Company — Each announcement includes:
- Basic information: date, securities code, abbreviation, original PDF link
- Extracted information: displayed in table format
extracted_info.infoinnon-empty fields(empty values automatically filtered) - No extracted information prompt: if a certain announcement
extracted_infois empty orinfofield does not exist, it will display_暂无提取信息_prompt, but still retains the announcement basic information and original link
- Product Promotion Footer — Memect product links
Optimized Design Principles
Human readability:
- ✅ Overall investment analysis at the top, letting investors see the core viewpoints and focus points at a glance
- ✅ Clear hierarchical structure (H1 → H2 → H3 → table/list)
- ✅ Use emoji icons to enhance visual recognition
- ✅ Tabular data structured for quick browsing
Machine scraping friendly:
- ✅ Standard Markdown syntax, easy to parse
- ✅ Uniform table format (field | content)
- ✅ Stable anchor titles (company name + securities code)
- ✅ Extensible: in the future, JSON-format structured data blocks can be added under company titles
Scraping suggestions: If other bots need to programmatically extract data, it is recommended to:
- By title
## 📍 {公司名}({证券代码})locate the company block - Use regular expressions to extract basic announcement information (date, link, etc.)
- Parse the table format to extract structured fields
Future enhancement directions:
- 🔮 Can add HTML comment markers in company blocks (such as
<!-- COMPANY_START:600519 -->) to assist parsing - 🔮 Optional JSON data block output mode (specifically for machine scraping)
- 🔮 Add announcement category tags (such as
#利好、#中性、#利空) for easy filtering
Publish to Lemmy Forum
Publish the generated Markdown post to Xia'er Community (Lemmy):
# 从文件发布
python3 scripts/publish_to_lemmy.py \
--title "【10家公司】董事会决议公告汇总(2026-02-11)【共15条】" \
--markdown-file post.md \
--community main
# 管道方式发布
python3 scripts/fetch_and_format.py --infotype "O_临时公告_董事会决议" | \
python3 scripts/publish_to_lemmy.py \
--title "【公告汇总】董事会决议" \
--community main
# 测试模式(不实际发布)
python3 scripts/publish_to_lemmy.py \
--title "测试标题" \
--content "测试内容" \
--community main \
--dry-run
Configuration Information(already built in, no modification needed):
- Forum address:http://xiaer.ai
- Username: xiaer01
- Default board: main
Custom Layout
If you need to adjust the layout format, modify scripts/fetch_and_format.py the following functions in:
format_extracted_info()— controls the table rendering of extracted informationformat_post()— controls the overall post structure and layoutINFOTYPE_DISPLAY— add Chinese mappings when adding new announcement types
Resources
- scripts/fetch_and_format.py — core script, fetch data + layout
- references/api_reference.md — API interface documentation, including response structure and field descriptions