citizens.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:bank_wrangler 作者: tmerr 项目源码 文件源码
def _download(config, tempdir):
    cfg_user, cfg_pass, *cfg_security = config

    driver = FirefoxDownloadDriver(tempdir, 'application/binary')
    driver.get('https://www.citizensbankonline.com/efs/servlet/efs/login.jsp')

    # Sign in
    user = driver.find_element_by_id('UserID')
    user.clear()
    user.send_keys(cfg_user.value)
    password = driver.find_element_by_id('currentpassword')
    password.clear()
    password.send_keys(cfg_pass.value)
    password.send_keys(Keys.RETURN)

    # Set an implicit wait (which defaults to 0) to save us from
    # accessing elements before they are ready.
    driver.implicitly_wait(30)

    # Switch into the AJAX-created frame that contains the security question
    # then answer it.
    driver.switch_to.frame(driver.find_element_by_name('mainFrame'))
    question_elem = driver.find_element_by_xpath("//label[@for='Response']")
    answer_elem = driver.find_element_by_id('Response')
    answer = _answer_security_question(question_elem.text, cfg_security)
    answer_elem.send_keys(answer)
    answer_elem.send_keys(Keys.RETURN)

    balances = _read_balances(driver)

    # Click "Download transactions", set options, and download.
    download_elem = driver.find_element_by_class_name('account-transactions-download')
    download_elem.click()
    driver.find_element_by_xpath('.//option[normalize-space(.) = "All Dates"]').click()
    driver.find_element_by_xpath('.//option[normalize-space(.) = "Comma Delimited"]').click()
    # Selenium sometimes misclicks the download button, so just call its onclick javascript.
    driver.execute_script('setFilterValues()')
    csv_path = driver.grab_download('EXPORT.CSV', timeout_seconds=30)

    driver.quit()
    return csv_path, balances
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号