クレジットカードの来月の支払いの確認が面倒くさい!
タイトルの通り、わたしは来月の支払いを確認するのを怠ったばっかりに、
何となくリボ払いにして借金が減った気がした錯覚に陥りました。
という事で、今回は前回と同じパターンで、
スクリプトでサクッと支払情報をサクッと貰ってきましょう。
例によってあなたがPCを起動した時に走らせるcronを使えば、全てのクレジットカードの支払を管理する事が出来ます。
カード会社毎に支払日が違うので、後々グラフ化も考えています。
グラフ化や、他の会社のクレジットカードの請求情報の取得解説の要望があったら言って下さい。
注意するべき点
__ 今回は特にないです。
OS:Windows10
GoogleChrome バージョン: 70.0.3538.110(Official Build) (64 ビット)
Python:3.70
Selenium Webdriver:この記事を書いた時点で最新のもの
chromedriver.exe:この記事を書いた時点で最新のもの
※スクリプトと同じフォルダに'chromedriver.exe'を置いてください。
recruit_card.py
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
browser = webdriver.Chrome()
browser.get('https://www2.cr.mufg.jp/newsplus/?cardBrand=0011&lid=news_mufg')
elem_username = browser.find_element_by_xpath('//*[@id="loginFormNavi"]/div/dl[1]/dd/input')
elem_username.send_keys('ID')
elem_password = browser.find_element_by_xpath('//*[@id="loginFormNavi"]/div/dl[2]/dd/input')
elem_password.send_keys('PASSWARD')
elem_login_btn = browser.find_element_by_xpath('//*[@id="submit1"]')
elem_login_btn.click()
elem_username = browser.find_element_by_xpath('//*[@id="webBirthDay"]')
elem_username.send_keys('190011')# 生年月。サンプルは1900年11月生まれ
elem_login_btn = browser.find_element_by_xpath('//*[@id="submit"]')
elem_login_btn.click()
elem_riyou = browser.find_element_by_xpath('//*[@id="pc_login"]/ul[1]/li[1]/a')
elem_riyou.click()
# ページ遷移対応
WebDriverWait(browser, 3).until(lambda d: len(d.window_handles) > 1)
browser.switch_to.window(browser.window_handles[1])
# 来月の支払代金を出力
elem_money_next_month = browser.find_element_by_xpath('//*[@id="main"]/div[3]/div[2]/table[2]/tbody/tr[1]')
elem_money_next_month.text
今回は以上になります。何かご要望があったらご意見下さい。