-1

我想从网上抓取我的网上银行网站。我有多个银行账户(在不同的银行),需要定期提取最新交易以查看我的总体支出并监控我的开支。目前我必须访问每个银行网站,提取提取物,将它们转储到 excel 文件中,执行一些重新格式化和过滤。我想自动化整个过程。首先要有一个程序,该程序可以自动从我的银行账户中提取转账历史记录。

我已经了解了使用请求和漂亮的汤库来抓取需要登录数据的网站。我了解您通常需要构建一个“有效负载”字典,其中包含:1. 用户名 2. 密码 3. 网站提供的令牌值

就我的大通银行而言,我找不到令牌值,但找到了以下行:

<div id=”securityToken” class=”logon-xs-toggle hidden”&gt;
    <input id=”securityToken-input-field” class=”jpui logon-xs-toggle” min=”0” placeholder=”Token” format=”” aria-describedby=“securityToken-placeHolderAdaText securityToken-helpertext” autocomplete=”off” maxlength=”35” name=”securityToken” data-validate=”securityToken” required=”” value=”” type=”tel”&gt;
    <span id=”securityToken-placeholderAdaText” class=”util accessible-text validation__accessible-text”&gt;Token</span>
</div>

如何确定我需要的 securityToken 值?谢谢

4

1 回答 1

1

使用 selenium 将使您摆脱登录请求和绕过其安全保护的所有麻烦,因为它是一个提供浏览器自动化的框架,就像真人导航一样。

Selenium 非常简单,一旦您安装它并在此处下载浏览器驱动程序,登录过程将如何使用 chrome 驱动程序

import selenium.webdriver as webdriver
import selenium.webdriver.support.ui as ui
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.common.exceptions import NoSuchElementException
from time import sleep

options = webdriver.ChromeOptions()
options.add_argument('--lang=EN')

driver = webdriver.Chrome(executable_path='assets\chromedriver', chrome_options=options)
driver.get("website loging url")
sleep(2)

driver.find_element_by_id("login").send_keys("username")
driver.find_element_by_id("password").send_keys("passowrd")
driver.find_element_by_id("submit_button").click()
于 2019-03-05T02:38:34.733 回答