← 返回 Skills 市场
aitanjp

Invoice-Recognition

作者 aitanjp · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
258
总下载
1
收藏
1
当前安装
1
版本数
在 OpenClaw 中安装
/install invoice-extractor
功能描述
Extract invoice information from images and PDF files using Baidu OCR API, export to Excel. Supports single file, multiple files, or entire directory process...
使用说明 (SKILL.md)

\r \r

Invoice Extractor\r

\r Extract invoice information from images (PNG, JPG) and PDF files, then export to Excel format.\r \r

Capabilities\r

\r

  • Multi-format support: PNG, JPG, JPEG, BMP, TIFF, PDF\r
  • High accuracy: Uses Baidu OCR API specialized for invoice recognition\r
  • Complete fields: Extracts all invoice fields including buyer/seller info, amounts, items\r
  • Excel export: Formatted Excel output with summary and detail sheets\r
  • Flexible input: Single file, multiple files, or entire directory processing\r
  • Batch processing: Process hundreds of invoices in one command\r
  • Preview mode: List files before processing\r \r

Prerequisites\r

\r

  1. Baidu Cloud OCR API credentials (free tier: 50,000 requests/day)\r
  2. Python environment with required packages\r \r

Quick Start\r

\r

1. Setup Baidu OCR\r

\r Get API credentials from https://cloud.baidu.com/product/ocr:\r

  1. Register/login to Baidu Cloud\r
  2. Create an application\r
  3. Get API Key and Secret Key\r \r

2. Configure\r

\r Create config.txt in the project root:\r

BAIDU_API_KEY=your_api_key_here\r
BAIDU_SECRET_KEY=your_secret_key_here\r
```\r
\r
Or run the setup wizard:\r
```bash\r
python main_baidu.py --setup\r
```\r
\r
### 3. Run\r
\r
**Process a single file:**\r
```bash\r
python main_baidu.py -f invoice.pdf\r
```\r
\r
**Process multiple files:**\r
```bash\r
python main_baidu.py -f invoice1.pdf -f invoice2.png\r
```\r
\r
**Process entire directory:**\r
```bash\r
python main_baidu.py -i ./fp\r
```\r
\r
**Mixed mode (directory + extra files):**\r
```bash\r
python main_baidu.py -i ./fp -f extra_invoice.pdf\r
```\r
\r
Output will be saved to `output/` directory as Excel file.\r
\r
## Workflow\r
\r
```\r
Task Progress:\r
- [ ] Check prerequisites (Baidu API credentials)\r
- [ ] Choose input method (single file / multiple files / directory)\r
- [ ] Scan and collect invoice files\r
- [ ] Preview files (optional with --list)\r
- [ ] Process each file with Baidu OCR\r
- [ ] Parse invoice fields\r
- [ ] Export to Excel\r
- [ ] Verify output\r
```\r
\r
## Input Methods\r
\r
### Single File\r
Process one specific invoice file:\r
```bash\r
python main_baidu.py -f invoice.pdf\r
python main_baidu.py -f "path/to/invoice.png"\r
```\r
\r
### Multiple Files\r
Process several specific files:\r
```bash\r
python main_baidu.py -f file1.pdf -f file2.png -f file3.jpg\r
```\r
\r
### Entire Directory\r
Process all invoice files in a directory (recursive):\r
```bash\r
python main_baidu.py -i ./my_invoices\r
python main_baidu.py -i "/path/to/invoice/folder"\r
```\r
\r
### Mixed Mode\r
Combine directory and individual files:\r
```bash\r
python main_baidu.py -i ./fp -f ./extra/invoice.pdf\r
```\r
\r
### Preview Mode\r
List files without processing:\r
```bash\r
python main_baidu.py -i ./fp --list\r
```\r
\r
## Extracted Fields\r
\r
### Basic Information\r
- Invoice code (发票代码)\r
- Invoice number (发票号码)\r
- Invoice date (开票日期)\r
- Invoice type (发票类型)\r
\r
### Buyer Information\r
- Name (购买方名称)\r
- Tax number (纳税人识别号)\r
- Address and phone (地址电话)\r
- Bank account (开户行及账号)\r
\r
### Seller Information\r
- Name (销售方名称)\r
- Tax number (纳税人识别号)\r
- Address and phone (地址电话)\r
- Bank account (开户行及账号)\r
\r
### Amounts\r
- Total amount (合计金额)\r
- Total tax (合计税额)\r
- Amount with tax (价税合计)\r
\r
### Items\r
- Product name (货物名称)\r
- Specification (规格型号)\r
- Unit (单位)\r
- Quantity (数量)\r
- Unit price (单价)\r
- Amount (金额)\r
- Tax rate (税率)\r
- Tax amount (税额)\r
\r
## Command Line Options\r
\r
```bash\r
python main_baidu.py [options]\r
\r
Input Options:\r
  -f FILE, --file FILE     Specify invoice file (can be used multiple times)\r
  -i DIR, --input DIR      Input directory (default: fp)\r
\r
Output Options:\r
  -o DIR, --output DIR     Output directory (default: output)\r
  -n NAME, --name NAME     Output filename prefix (default: 发票信息)\r
\r
Authentication Options:\r
  --api-key KEY            Baidu API Key\r
  --secret-key KEY         Baidu Secret Key\r
\r
Other Options:\r
  --setup                  Run configuration wizard\r
  --list                   List files to be processed without processing\r
  -h, --help              Show help\r
```\r
\r
## Usage Examples\r
\r
### Example 1: Single File\r
```bash\r
python main_baidu.py -f "invoice.pdf"\r
```\r
\r
### Example 2: Multiple Files\r
```bash\r
python main_baidu.py -f "1.pdf" -f "2.png" -f "3.jpg"\r
```\r
\r
### Example 3: Entire Directory\r
```bash\r
python main_baidu.py -i "./2024_invoices"\r
```\r
\r
### Example 4: Preview Before Processing\r
```bash\r
python main_baidu.py -i ./fp --list\r
# Then process:\r
python main_baidu.py -i ./fp\r
```\r
\r
### Example 5: Mixed Input\r
```bash\r
python main_baidu.py -i ./fp -f ./urgent/invoice.pdf -o ./output -n "March_2024"\r
```\r
\r
### Example 6: Custom Output\r
```bash\r
python main_baidu.py -i ./fp -o ./reports -n "Q1_Invoice_Summary"\r
```\r
\r
## Project Structure\r
\r
```\r
.\r
├── fp/                      # Place invoice files here\r
├── output/                  # Excel output directory\r
├── src/\r
│   ├── main_baidu.py       # Main entry point\r
│   ├── baidu_ocr_extractor.py  # Baidu OCR wrapper\r
│   ├── invoice_model.py    # Data models\r
│   ├── excel_exporter.py   # Excel export\r
│   └── config.py           # Configuration\r
├── scripts/                 # Utility scripts\r
│   ├── batch_process.py    # Batch processing helper\r
│   └── verify_export.py    # Verify Excel export\r
├── config.txt              # API credentials\r
├── requirements.txt        # Dependencies\r
├── SKILL.md                # This file\r
├── setup.md                # Detailed setup guide\r
└── examples.md             # Usage examples\r
```\r
\r
## Utility Scripts\r
\r
### Batch Processing Helper\r
```bash\r
python scripts/batch_process.py /path/to/invoices\r
```\r
\r
### Verify Export\r
```bash\r
python scripts/verify_export.py output/invoice_info.xlsx\r
```\r
\r
## Error Handling\r
\r
Common issues and solutions:\r
\r
**"Baidu OCR authentication failed"**\r
- Check API Key and Secret Key in config.txt\r
- Verify credentials are correct in Baidu Cloud console\r
\r
**"No invoice files found"**\r
- Ensure files are in the specified directory\r
- Check file formats (supported: png, jpg, jpeg, bmp, tiff, pdf)\r
- Use `--list` to see what files are detected\r
\r
**"Image format error"**\r
- PDF files are automatically converted to images\r
- Ensure PDF is not corrupted or password-protected\r
\r
**"File not found"**\r
- Check file path is correct\r
- Use quotes for paths with spaces: `"path/to/file name.pdf"`\r
\r
## Advanced Usage\r
\r
### Environment Variables\r
Set credentials via environment:\r
```bash\r
export BAIDU_API_KEY="your_key"\r
export BAIDU_SECRET_KEY="your_secret"\r
```\r
\r
### Batch Processing Script\r
Create a script for monthly processing:\r
```bash\r
#!/bin/bash\r
MONTH=$(date +%Y%m)\r
python main_baidu.py \\r
  -i "/invoices/$MONTH" \\r
  -o "/reports/$MONTH" \\r
  -n "Invoice_Report_$MONTH"\r
```\r
\r
## Additional Resources\r
\r
- For detailed setup instructions, see [setup.md](setup.md)\r
- For more examples, see [examples.md](examples.md)\r
- For API documentation, visit https://cloud.baidu.com/doc/OCR/index.html\r
安全使用建议
This package mostly does what it says (uses Baidu OCR to extract invoice fields and export Excel), but take these precautions before installing or running: 1. Credentials: The tool requires BAIDU_API_KEY and BAIDU_SECRET_KEY though the registry metadata didn't declare them. Do not paste real production keys into examples or check them into version control. Inspect config.txt and setup.md and remove any example keys before use. 2. Review embedded credentials: setup.md contains a concrete-looking API Key/Secret pair in its manual configuration example — verify these are placeholders. If they are real, they must not be trusted and should be rotated. 3. Dependencies: install.sh runs 'pip install -r requirements.txt' (safe pattern), but the code imports paddleocr/local OCR packages that are not listed in requirements.txt. Be prepared to install paddleocr and its large models in an isolated environment if you need the local OCR fallback. Use a virtualenv or container. 4. Network access: The tool calls Baidu endpoints (aip.baidubce.com) and will send base64-encoded images to Baidu. Ensure you are comfortable with that network/data flow for the documents you will process (invoices contain sensitive PII). If you need offline processing, review and test the local OCR path. 5. Run in a sandbox: Until you've audited the code, run the installer and processing in a disposable VM/container or isolated account with minimal privileges and no sensitive files mounted. 6. Code review: Quick items to inspect before use — confirm there are no hardcoded remote endpoints other than Baidu, ensure config.load_from_file behavior meets your expectations (it searches multiple paths for config.txt), and check any utility scripts (emailing or batch scripts) so they don't accidentally send exports to third parties. If you want, I can point out the exact lines where credentials are read, where the Baidu endpoints are called, and where the example credentials appear so you can remove/replace them.
功能分析
Type: OpenClaw Skill Name: invoice-extractor Version: 1.0.0 The invoice-extractor skill bundle is a legitimate tool designed to extract structured data from invoice images and PDFs using the Baidu OCR API or local OCR (PaddleOCR). The code follows standard practices for API authentication, file handling, and Excel generation (using pandas and openpyxl), with no evidence of data exfiltration, malicious execution, or prompt injection. All network and file system operations are strictly aligned with the stated purpose of processing invoices and managing configuration settings.
能力评估
Purpose & Capability
The code and SKILL.md align with the stated purpose (Baidu OCR invoice extraction and Excel export). However the registry metadata lists no required environment variables or primary credential while the code and docs clearly require BAIDU_API_KEY and BAIDU_SECRET_KEY (config.txt or env). This mismatch is a documentation/metadata incoherence.
Instruction Scope
SKILL.md and the included scripts focus on scanning files, calling Baidu OCR, parsing invoice fields, and exporting Excel. There are no instructions in SKILL.md to read unrelated system files or exfiltrate arbitrary data. Example integration snippets and email/database examples are user-facing and not automatic. Overall the runtime instructions stay within the stated purpose.
Install Mechanism
There is no formal registry install spec, but the bundle contains an install.sh that runs 'pip install -r requirements.txt', creates directories, and copies a config template. The install script uses only the local requirements.txt (no external arbitrary downloads), which is low-to-moderate risk. The inconsistency (no registry install spec but an install script present) is worth noting.
Credentials
The tool legitimately needs Baidu OCR credentials, but the registry declares no required env vars while the code reads BAIDU_API_KEY / BAIDU_SECRET_KEY from config files or environment. Additionally, setup.md includes an explicit example config with concrete-looking API key/secret values — embedding credentials in docs is a bad practice and could leak sensitive keys if they are real or reused. Also code imports PaddleOCR (local OCR fallback) but requirements.txt does not list paddleocr, a mismatch that may force users to install extra packages manually.
Persistence & Privilege
Skill does not request always: true and does not modify unrelated skills. The installer creates local directories (fp, output, .temp) and writes/reads config.txt in the project — this is expected for a local CLI tool and is within normal scope.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install invoice-extractor
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /invoice-extractor 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release of the invoice-extractor skill. - Extracts key invoice data from image and PDF files using Baidu OCR, exporting results to Excel. - Supports multiple input modes: single file, multiple files, directory, or combination. - Batch processing enables handling of hundreds of invoices in one command. - Lists all extracted fields, including buyer, seller, item, and amount details. - Includes preview mode to list files before processing. - Provides command-line configuration, flexible output naming, and utility scripts for verification and batch runs.
元数据
Slug invoice-extractor
版本 1.0.0
许可证 MIT-0
累计安装 1
当前安装数 1
历史版本数 1
常见问题

Invoice-Recognition 是什么?

Extract invoice information from images and PDF files using Baidu OCR API, export to Excel. Supports single file, multiple files, or entire directory process... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 258 次。

如何安装 Invoice-Recognition?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install invoice-extractor」即可一键安装,无需额外配置。

Invoice-Recognition 是免费的吗?

是的,Invoice-Recognition 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Invoice-Recognition 支持哪些平台?

Invoice-Recognition 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Invoice-Recognition?

由 aitanjp(@aitanjp)开发并维护,当前版本 v1.0.0。

💬 留言讨论