Install
openclaw skills install cn-financial-notes-extraction提取中国 A 股上市公司年报 (PDF) 中的财务报表附注明细。适用于获取主表无法体现的深层数据(如 CapEx 明细、研发费用细分、应收账款账龄、关联方交易等)。
openclaw skills install cn-financial-notes-extraction从巨潮资讯 (CNINFO) 下载的年报 PDF 中,精准定位并提取财务报表附注中的表格数据。
CNInfo API Scraper 或 East Money Announcement Downloader 下载最新年报 PDF。pdfplumber (系统 Python 环境) 打开 PDF,全文检索关键字 财务报表附注。extract_tables())。项目, 期末余额, 本期增加, 本期减少, 账面余额)筛选有效表格。Dict[List] 或 DataFrame 格式输出。import pdfplumber
def extract_notes(pdf_path, keywords=None):
found_data = []
with pdfplumber.open(pdf_path) as pdf:
# 1. 定位附注起始页
start_idx = 0
for i, page in enumerate(pdf.pages):
text = page.extract_text()
if text and "财务报表附注" in text:
start_idx = i
break
# 2. 扫描表格
for i in range(start_idx, len(pdf.pages)):
page = pdf.pages[i]
tables = page.extract_tables()
for table in tables:
# 过滤空表或短表
if len(table) > 3 and any(row[0] for row in table if row):
# 可选:如果指定了 keywords,检查表头是否匹配
if keywords:
headers = " ".join([str(c) for c in table[0] if c])
if any(kw in headers for kw in keywords):
found_data.append({"page": i+1, "table": table})
else:
found_data.append({"page": i+1, "table": table})
return found_data
python3 和 pdfplumber,不要在沙箱 (subagent) 中直接运行,除非确认安装了库。pdfplumber 效果最佳。