jsm*_*iao 13 python selenium google-chrome webdriver selenium-chromedriver
当我尝试使用Selenium(Python)登录Chase网站时,我遇到以下错误消息:
但是,使用"人"登录工作正常.似乎当Selenium找到一个元素时会引发问题.
我错过了什么吗?我试图在stackoverflow上找到答案,但无济于事.
预期的结果是脚本将成功允许我以编程方式登录.
这是下面的代码示例:
import time
import os
from selenium import webdriver
CHASE_USER_ID = os.getenv('CHASE_USER_ID', None)
CHASE_PASSWORD = os.getenv('CHASE_PASSWORD', None)
assert CHASE_USER_ID is not None, 'Chase user id not set'
assert CHASE_PASSWORD is not None, ' Chase password not set'
def main():
chrome_options = webdriver.ChromeOptions()
driver = webdriver.Chrome(r'./chromedriver', chrome_options=chrome_options)
try:
driver.get('https://secure07c.chase.com/web/auth/#/logon/logon/chaseOnline?')
time.sleep(2)
user_element = driver.find_element_by_id('userId-input-field') # Finding an element here seems to make the login process fail
user_element.send_keys(CHASE_USER_ID)
password_element = driver.find_element_by_id('password-input-field')
password_element.send_keys(CHASE_PASSWORD)
time.sleep(2)
password_element.submit()
time.sleep(10)
finally:
driver.quit()
if __name__ == '__main__':
main()
Run Code Online (Sandbox Code Playgroud)
我拿了你的代码并简化了结构,用最少的代码行运行测试,如下所示:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
options.add_argument("--disable-extensions")
driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
driver.get("https://secure07c.chase.com/web/auth/#/logon/logon/chaseOnline?")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.jpui.input.logon-xs-toggle.clientSideError"))).send_keys("jsmiao")
driver.find_element_by_css_selector("input.jpui.input.logon-xs-toggle#password-input-field").send_keys("hello")
driver.find_element_by_css_selector("button#signin-button>span.label").click()
Run Code Online (Sandbox Code Playgroud)
同样,根据你的观察,我遇到了同样的障碍,错误如下:

似乎在click()带有文本的元素上登录确实发生了.虽然已启动用户名/密码查找但该过程已中断.在检查网页的DOM树时,您会发现某些标记指的是具有关键字dist的JavaScripts.举个例子:<script>
<script src="https://static.chasecdn.com/web/library/blue-boot/dist/2.20.3/blue-boot/js/main-ver.js"></script><script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="blue-vendor/main" src="https://static.chasecdn.com/web/library/blue-vendor/dist/2.11.1/blue-vendor/js/main.js"></script><script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="blue/main" src="https://static.chasecdn.com/web/library/blue-core/dist/2.16.3/blue/js/main.js"></script><script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="blue-app/main" src="https://static.chasecdn.com/web/library/blue-app/dist/2.15.1/blue-app/js/main.js"></script>这清楚地表明该网站受到Bot Management服务提供商Distil Networks的保护,并且ChromeDriver的导航会被检测到并随后被阻止.
根据文章那里真的有关于Distil.it ...的东西...:
Distil通过观察站点行为和识别刮板特有的模式来保护站点免受自动内容抓取机器人的攻击.当Distil在一个站点上识别出恶意僵尸程序时,它会创建一个列入其所有客户的黑名单行为配置文件.像机器人防火墙一样,Distil检测模式并做出反应.
进一步,
"One pattern with **Selenium** was automating the theft of Web content"迪斯蒂尔首席执行官拉米·赛赛德上周接受采访时表示."Even though they can create new bots, we figured out a way to identify Selenium the a tool they're using, so we're blocking Selenium no matter how many times they iterate on that bot. We're doing that now with Python and a lot of different technologies. Once we see a pattern emerge from one type of bot, then we work to reverse engineer the technology they use and identify it as malicious".
您可以在以下位置找到几个详细的讨论:
| 归档时间: |
|
| 查看次数: |
1836 次 |
| 最近记录: |