I made a module PyNanaco that can charge nanaco credit with python

GitHub PyNanaco

What is this

--You can use selenium to access the nanaco web page to log in / log out, charge your credit card, and set / cancel your credit card. ――You can charge up to 50,000 yen with one command.

merit

--Since you can charge 50,000 yen with one operation, it is easier than operating the web screen --The work of setting / canceling credit cards for multiple nanaco cards can be described in just a few lines. --If you link it with cron or scheduler separately, you can charge nanaco and change credit card settings by batch processing.

Installation method

I haven't registered with PyPI, so please use Git.

pip install git+https://github.com/sawadyrr5/PyNanaco

Selenium should be installed at the time of installation, but if not, please install with pip install selenium.

You need to put chromedriver.exe in the same location as core.py. Click here to get it. chrome webdriver

Method explanation

login(nanaco_number, card_number, password)

Log in to the nanaco menu screen. Enter * card_number * to log in with the number on the card, * password * to log in with your mobile member password. (If you enter both, * card_number * has priority) If you prepare nanaco information in dict type in advance, you can log in like this.

python


my_nanaco = dict(
    nanaco_number='xxxxxxxxxxxxxxxx',
    card_number='yyyyyyy'
)

nanaco = PyNanaco()
nanaco.login(**my_nanaco)

login_credit_charge(credit_charge_password)

The screen will change to the credit charge screen. If the credit charge is already registered, the registered card number will be returned. (A string such as'xxxx-xxxx-xxxx-1234') If the credit charge is not registered, the screen will change to the credit charge information screen.

history()

Get credit shard history. Returns `` `dict (charged_count = x, charged_amount = y) ``` as the return value.

charge(value)

I will charge. You can enter value in increments of 1,000 yen up to 50,000 yen. If it exceeds 30,000 yen, the charge will be processed separately so that the second time will be at least 5,000 yen. (Example: 50,000 yen = 30,000 yen + 20,000 yen 31,000 yen = 26,000 yen + 5,000 yen) If a PGSE09 error occurs during processing, it will stop with a PyNanacoCreditChargeError exception.

register(credit, profile, secure)

Set your credit card information. Specify credit and profile as dict type and secure as a string. (The interface here is not well organized and may be changed later).

python


my_card = dict(
    number='xxxxxxxxxxxxxxxx',
    expire_month='mm',
    expire_year='yyyy',
    code='xxx',
    phone='xxxxxxxxxxx'
)

my_profile = dict(
    name='john doe',
    birthday=datetime(1980, 1, 1),
    password='xxxxxxxx',
    mail='[email protected]',
    send_information='2'
)

secure='secure_password_here'

When you perform register, please executelogin_credit_charge ()in advance.

python


    nanaco = PyNanaco()
    nanaco.login_by_card(**my_nanaco)
    nanaco.login_credit_charge()
    nanaco.register(
        credit=my_card,
        profile=my_profile,
        secure='set_secure_password_here'
    )

cancel()

Unset your credit card. You need to log in to the credit charge menu with login_credit_charge () in advance.

logout()

Log out.

quit()

Exit the chromedriver.

Sample code

python


# -*- coding: utf-8 -*-
from datetime import datetime

from pynanaco.core import PyNanaco

# set your nanaco card information.
# (credit charge ready.)
my_nanaco = dict(
    nanaco_number='xxxxxxxxxxxxxxxx',
    card_number='yyyyyyy'
)

# set your nanaco card information.
# (credit charge not ready.)
my_nanaco2 = dict(
    nanaco_number='xxxxxxxxxxxxxxxx',
    card_number='yyyyyyy'
)

# set your credit-card information.
my_card = dict(
    number='xxxxxxxxxxxxxxxx',
    expire_month='mm',
    expire_year='yyyy',
    code='xxx',
    phone='xxxxxxxxxxx'
)

# set your profile.
my_profile = dict(
    name='john doe',
    birthday=datetime(1980, 1, 1),
    password='xxxxxxxx',
    mail='[email protected]',
    send_information='2'
)


def example_charge():
    nanaco = PyNanaco()
    nanaco.login(**my_nanaco)
    nanaco.login_credit_charge('set_credit_charge_password_here')
    nanaco.charge(10000)


def example_register():
    nanaco = PyNanaco()
    nanaco.login(**my_nanaco2)
    nanaco.login_credit_charge()
    nanaco.register(
        credit=my_card,
        profile=my_profile,
        secure='set_secure_password_here'
    )


def example_cancel():
    nanaco = PyNanaco()
    nanaco.login(**my_nanaco)
    nanaco.login_credit_charge('set_credit_charge_password_here')
    nanaco.cancel()


if __name__ == '__main__':
    example_charge()
    example_set()
    example_cancel()

Ingenuity

--The PageObjects pattern was adopted to minimize the impact of design changes on the site side, and the description of pages and methods is summarized in page.py, and the description of page element selectors is summarized in locators.py.

Task

--Implementation of error handling (charge 15 times or more per month, charge 200,000 yen or more per month, etc.)

Recommended Posts

I made a module PyNanaco that can charge nanaco credit with python
I made a shuffle that can be reset (reverted) with Python
I made a familiar function that can be used in statistics with Python
I made a fortune with Python.
I made a daemon with Python
I made a plug-in that can "Daruma-san fell" with Minecraft
I made a character counter with Python
I made a Hex map with Python
I made a roguelike game with Python
I made a configuration file with Python
[python] I made a class that can write a file tree quickly
I made a competitive programming glossary with Python
I made a weather forecast bot-like with Python.
I made a GUI application with Python + PyQt5
I made a Twitter fujoshi blocker with Python ①
[Python] I made a Youtube Downloader with Tkinter.
[Python] I made a utility that can access dict type like a path
I made a tool that makes decompression a little easier with CLI (Python3)
I made a bin picking game with Python
I made a Mattermost bot with Python (+ Flask)
I registered PyQCheck, a library that can perform QuickCheck with Python, in PyPI.
I made a Docker image that can call FBX SDK Python from Node.js
A story that I was addicted to when I made SFTP communication with python
I made a Twitter BOT with GAE (python) (with a reference)
I made a Christmas tree lighting game with Python
I made a net news notification app with Python
I made a Python module to translate comment outs
I made a Python3 environment on Ubuntu with direnv.
I made a LINE BOT with Python and Heroku
A memo that I touched the Datastore with python
I made a python text
I made blackjack with Python.
I made wordcloud with Python.
A story that stumbled when I made a chatbot with Transformer
I made a simple typing game with tkinter in Python
I made a LINE BOT that returns parrots with Go
Why can I use the module by importing with python?
I made a package to filter time series with python
I made a simple book application with python + Flask ~ Introduction ~
I made a puzzle game (like) with Tkinter in Python
I made a rigid Pomodoro timer that works with CUI
I made a Line-bot using Python!
I made a program to collect images in tweets that I liked on twitter with Python
I made a module that can be glitched easily, but I can't pass arguments from entry_points
I made a simple circuit with Python (AND, OR, NOR, etc.)
[Python] Make a graph that can be moved around with Plotly
I made a library to easily read config files with Python
[Python3] I made a decorator that declares undefined functions and methods.
[Python] I made my own library that can be imported dynamically
[Python] A memo that I tried to get started with asyncio
I made a Nyanko tweet form with Python, Flask and Heroku
I made a lot of files for RDP connection with Python
[Python] I made an image viewer with a simple sorting function.
I made a poker game server chat-holdem using websocket with python
I made a library that adds docstring to a Python stub file.
I made a segment tree with python, so I will introduce it
I made a program that automatically calculates the zodiac with tkinter
The story of making a module that skips mail with python
A story that didn't work when I tried to log in with the Python requests module
[Python] A program that creates stairs with #
I made a payroll program in Python!