Skip to content

Instantly share code, notes, and snippets.

@sleepless-se
Last active November 15, 2018 14:14
Show Gist options
  • Save sleepless-se/8712585572b133d4931f6c11cd7a9c5e to your computer and use it in GitHub Desktop.
Save sleepless-se/8712585572b133d4931f6c11cd7a9c5e to your computer and use it in GitHub Desktop.
マネーフォワードに登録している金融機関を自動更新するスクリプト
from selenium import webdriver
import logging
import time
import sys
args = sys.argv
_format = "%(asctime)s %(levelname)s %(name)s :%(message)s"
logging.basicConfig(filename="moneyforward_reload_account.log", level=logging.DEBUG, format=_format)
global driver
driver = None
def login(email,password):
driver.get("https://moneyforward.com/users/sign_in")
time.sleep(3)
driver.find_element_by_xpath("//*[@id='sign_in_session_service_email']").send_keys(email)
driver.find_element_by_xpath("//*[@id='sign_in_session_service_password']").send_keys(password)
driver.find_element_by_xpath("//*[@id='login-btn-sumit']").click()
time.sleep(3)
def open_accounts_page():
driver.get("https://moneyforward.com/accounts")
def click_reloads():
elms = driver.find_elements_by_xpath("//input[@data-disable-with='更新']")
for elm in elms:
elm.click()
time.sleep(0.5)
time.sleep(5)
if __name__ == '__main__':
try:
driver = webdriver.Chrome(executable_path="/usr/local/bin/chromedriver") # local
login(args[1], args[2])
open_accounts_page()
click_reloads()
logging.info("DONE")
except Exception as e:
logging.error(e)
finally:
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment