Batch-download formal A-share annual and semiannual report PDFs from CNInfo (巨潮资讯) using a stock-code CSV. Supports dry-run preview, resume on failure, force...
批量下载A股上市公司年报/半年报 PDF(数据源:巨潮资讯 cninfo.com.cn)。
bash
pip install -r requirements.txt
--dry-run first to preview matches without downloading.runtime/manifest_<year>.csv and runtime/logs/cninfo_<year>.log after the run.Normal download (default year 2025):
bash
python scripts/run_cninfo_reports.py --stock-csv <path-to-csv>
Dry-run (preview only, no download):
bash
python scripts/run_cninfo_reports.py --stock-csv <path-to-csv> --dry-run
Specify year:
bash
python scripts/run_cninfo_reports.py --stock-csv <path-to-csv> --year 2024
Force redownload (ignore cache):
bash
python scripts/run_cninfo_reports.py --stock-csv <path-to-csv> --force-redownload
Full CLI options:
ArgumentDefaultDescription--year2025Target report year--stock-csv``上市公司基础信息.csvCSV with stock codes in column 1--output-dir``downloads/<year>PDF output directory--runtime-dir``runtimeState, manifest, logs directory--page-size20Search results per page--sleep-seconds1.2Min delay between requests--timeout-seconds30HTTP timeout--max-retries5HTTP retry attempts--dry-runfalsePreview matches without downloading--force-redownloadfalseRe-download even if file exists
runtime/manifest_<year>.csv with full metadata for every eligible report.{code}_{year}_{kind}.pdf for primary files, extra variants get _{announcement_id} suffix.text
scripts/
run_cninfo_reports.py # Entry point
cninfo_annual_reports/
cli.py # Argument parsing & logging
config.py # AppConfig dataclass
service.py # Core orchestration logic
repository.py # SQLite state management
http_client.py # CNInfo API & file download
models.py # Data models
filters.py # Title evaluation & regex
references/
filter_rules.md # Detailed filter/reset docs
agents/
openai.yaml # Codex integration config
To restart from scratch, delete state files:
bash
rm runtime/state.db runtime/state.db-wal runtime/state.db-shm