Skip to main content

Download billing files from email with configurable providers

Project description

Emlex

Emlex 从邮箱中查找支付宝、微信等账单邮件,并把附件或邮件中的下载链接保存到本地。

安装

项目要求 Python 3.10 及以上版本:

python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e ".[dev]"

安装后使用 em 命令,也可以在源码目录运行 python -m cli.main

交互式添加邮箱

启动终端配置向导:

em config email add

向导支持:

  • Gmail(建议使用应用专用密码);
  • 任意支持 SSL 的 IMAP 邮箱;
  • 支付宝和微信账单配置;
  • 更新已有邮箱时保留下载方式和账单匹配规则;
  • 密码隐藏输入、写入前确认以及 0600 配置文件权限。

如果不希望把密码直接写入 JSON,可保存环境变量引用:

em config email add \
  --provider alipay \
  --email-type gmail \
  --username you@example.com \
  --password-env EMLEX_EMAIL_PASSWORD

然后在 ~/.flow/.env 中设置密码:

EMLEX_EMAIL_PASSWORD=your-app-password

自定义 IMAP 示例:

em config email add \
  --provider wechat \
  --email-type imap \
  --username you@example.com \
  --host imap.example.com \
  --port 993

默认配置文件为 ~/.flow/config.json。开发和测试时可通过 --config 指定其他路径。

下载账单

em download --provider alipay
em download --provider wechat

使用其他配置文件:

em download --provider alipay --config /path/to/config.json

首次添加邮箱时,向导会生成可用的最小 provider 配置。你可以继续编辑 profile 来精确匹配邮件:

{
  "alipay": {
    "email": "gmail",
    "auth_type": "pass",
    "auth": {
      "username": "you@example.com",
      "password": "${EMLEX_EMAIL_PASSWORD}"
    },
    "download": "attachment",
    "profile": {
      "name": "alipay",
      "search_subject": "支付宝",
      "sender_email": "service@example.com",
      "file_suffix": "zip",
      "encoding": "gbk"
    }
  }
}

download 可设为 attachment(兼容旧拼写 attchment)或 link。下载文件默认保存在 ~/.flow/data/<provider>/

测试

python -m pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

emlex-1.1.0.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

emlex-1.1.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file emlex-1.1.0.tar.gz.

File metadata

  • Download URL: emlex-1.1.0.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for emlex-1.1.0.tar.gz
Algorithm Hash digest
SHA256 436fefa07d0b1c60c1f2e3e6a90478a0f91218e917d566e5179a7e4f26c8757a
MD5 0e222b7c2cf7eee93faf8264ec95f806
BLAKE2b-256 d250c621d4bbc3507cdcf3fff858b6dd037c20c921c1869f57678add40cb4e62

See more details on using hashes here.

File details

Details for the file emlex-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: emlex-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for emlex-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 49e18689cfd01af8f35ac31bf83ed22c66ec11506dfc2fde77532bde64f293a6
MD5 7d7e450333b78b6bacf4377a327f7f48
BLAKE2b-256 710077244618dd4e82812124e7c04350c974d9f4581d695c131790ca77bb8784

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page