Skip to main content

MySoftBank dataTraffic

Project description

MySB_dataTraffic

MySoftBankをスクレイピングしてデータ残量をLINEに通知するやつ

Install

GitHubから直接Cloneすることを推奨します。この方法の場合はMySB_dataTrafficディレクトリ内のsample.pyを書き換えることで使用することができます。

$ git clone https://github.com/0x0u/MySB_dataTraffic
$ cd MySB_dataTraffic

pipでのインストールも可能です。

$ pip3 install MySB-datatraffic

How to use

ライブラリのインポート

import MySBdt

LINE通知にはLINE Notifyを使用するのでアクセストークンを取得しておく必要があります。telnum、password、line_access_tokenを自分のものに置き変えます。

telnum = "電話番号"
password = "MySoftbankのパスワード"
line_access_token = "LineNotifyのアクセストークン"

インスタンスを作成

api = MySBdt.API(telnum=telnum, password=password, line_access_token=line_access_token)

データ(使用量、残量、繰越残量、追加量、追加使用量、追加繰越量、追加繰越使用量)の取得ができます。

data = api.get_data()
print(data)

# 実行結果
# {'used_data': 6.34, 'remain_data': 0.02, 'step_remain_data': 0.0, 'additional_data': 1.0, 'additional_used_data': 0.98, 'given_data': 0.36, 'given_used_data': 0.36}

LINEに通知します。

status = api.send_message()
print(status)

# 実行結果
# 200

実行すると以下のような情報がLINEに通知されます。戻り値はrequestsのHTTPステータスコードが返ります。

Author

@qxi_(https://twitter.com/qxi_)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

MySB_datatraffic-4.1-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

Supported by

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