pyzaim
Zaimのデータを取得・操作するPythonパッケージ
概要
大きくわけて2つの処理を行うパッケージです。
- Zaim APIのラッパークラス
- Zaim APIのアクセストークンの発行
- Rest APIとして提供されている処理の実行
- Seleniumを用いたデータ取得
- Zaimにはクレジットカードや銀行口座から自動でデータ取得する機能があるが、APIではそれらのデータにはアクセスできない
- これらの情報を取得するため、Seleniumのwebdriver(Chrome)を用いてデータを取得
インストール
pip install pyzaim
準備
- Zaimアカウントの作成
- Zaim Developersでのアプリケーションの登録 (コンシューマID、コンシューマシークレットの発行)
- Google Chromeおよびseleniumの導入
使い方
Zaim APIのラッパークラスの使い方
- アクセストークンの発行
from pyzaim import get_access_token
get_access_token()
# コンシューマIDとコンシューマシークレットを聞かれるので入力
# 認証ページのURLが表示されるので、アクセスして許可
# 遷移先ページのソースコードから「oauth_verifier」と書いてあるコードをコピーして入力
# 問題なければアクセストークンとアクセスシークレットが表示される
- APIを利用してデータを取得・操作
from pyzaim import ZaimAPI
api = ZaimAPI('コンシューマID', 'コンシューマシークレット',
'アクセストークン', 'アクセスシークレット', 'verifier')
# 動作確認 (ユーザーID等のデータが取得されて、表示されればOK)
print(api.verify())
# データの取得
data = api.get_data()
# 支払いデータの登録
api.insert_payment_simple('日付(datetime.date型)', '金額(int)', 'ジャンル名',
'口座名', 'コメント', '品名', '店舗名') # 後半4つは任意入力
# 使用できるジャンル名は以下で確認できる
print(api.genre_itos)
# 使用できる口座名は以下で確認できる
print(api.account_itos)
# 支払いデータの更新 (更新対象データのIDはapi.get_data()で確認)
api.update_payment_simple('更新対象データのID', '日付(datetime.date型)', '金額(int)',
'ジャンル名', '口座名', 'コメント', '品名', '店舗名') # 後半4つは任意入力
# 支払いデータの削除
api.delete_payment('削除対象のデータのID')
seleniumを用いたデータ取得
from pyzaim import ZaimCrawler
# Chrome Driverの起動とZaimへのログイン、ログインには少し時間がかかります
crawler = ZaimCrawler('ログインID', 'ログインパスワード',
driver_path='Chrome Driverのパス'(PATHが通っていれば省略可),
headless=False) # headlessをTrueにするとヘッドレスブラウザで実行できる
# データの取得 (データの取得には少し時間がかかります、時間はデータ件数による)
data = crawler.get_data('取得する年(int)', '取得する月(int)', progress=True) # progressをFalseにするとプログレスバーを非表示にできる
# 終了処理
crawler.close()
ブランチの運用について
本リポジトリのブランチについては以下の運用といたします。
main
- リリース用ブランチ。
- このブランチにマージした時点で新たにタグを打ち、PyPIにアップロードします。
- このブランチには直接PRを出さないでください。
develop
- 開発用の常駐ブランチ。
- すべてのコミットはこのブランチに一度マージし、動作を確認した上でmainにマージします。
- PRはこのブランチに対して行ってください。
feature-*
- 新規開発用のブランチ。
- 必ずdevelopから分岐し、developにマージする。
*には開発やバグ修正などの対応内容を簡潔に記入。- 例: feature-add-headless-mode
Contributors ✨
Thanks goes to these wonderful people (emoji key):
りーべ 📆 👀 💻 📖 |
Ponk02 💻 |
zenjiro 💻 👀 |
omatsu555 💻 |
Y.Tory 💻 |
o-matsu 💻 |
kefi550 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
Metadata
Release files for pyzaim 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyzaim-1.1.0.tar.gz | 10.4 kB | Without provenance | Details for pyzaim-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyzaim-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for pyzaim-1.1.0-py3-none-any.whl |
Total release size: 19.1 kB
Release files / pyzaim-1.1.0.tar.gz
| Download URL | pyzaim-1.1.0.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe21581c03af6ac52bb4a57add0a0573f2cc1738b353a72db308d168a8ed09bb
|
|
BLAKE2b-256 checksum How to use checksums |
3a9ebb86ed92f157ac8ab7458512769ac368bd0d290a141add70545414ae169a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.10.12 Linux/5.15.146.1-microsoft-standard-WSL2
|
Release files / pyzaim-1.1.0-py3-none-any.whl
| Download URL | pyzaim-1.1.0-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
df67e7789f11fc9509956d5842ca4b3d541da95bec77180b1db8e526e6176d42
|
|
BLAKE2b-256 checksum How to use checksums |
c97bc0daff080f137036d262577fa789b92b0f1805eeaf2b955bc75057f64479
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.10.12 Linux/5.15.146.1-microsoft-standard-WSL2
|
Security for pyzaim 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.