【问题标题】:error: selenium.common.exceptions.TimeoutException: Message:错误:selenium.common.exceptions.TimeoutException:消息:
【发布时间】:2021-04-20 00:34:00
【问题描述】:

在下面的代码中,我尝试使用 selenium 登录网站但我收到此错误 selenium.common.exceptions.TimeoutException: Message:

提前致谢

代码

from selenium import webdriver
from bs4 import BeautifulSoup
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

URL = 'website'
options = webdriver.ChromeOptions()
options.add_argument("headless")
options.add_argument('--no-sandbox')   
options.add_argument('--disable-dev-shm-usage')
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(options=options)
driver.get(URL)
wait = WebDriverWait(driver, 10)
#-------------------------------------------------------------------

wait.until(EC.presence_of_element_located((By.ID,"username"))).send_keys("nocsud")
wait.until(EC.presence_of_element_located((By.ID,"value"))).send_keys("noc_sud10")
driver.find_element_by_id("submitDataverify").click()


#-------------------------------------------------------------------
soup = BeautifulSoup(driver.page_source, 'html.parser')
driver.quit()
root = soup.find(id='root')
print(root)

【问题讨论】:

    标签: python selenium web-scraping webautomation


    【解决方案1】:

    我建议您使用 options.add_argument("interactive") 让您查看网页中发生的情况以及代码在哪里停止, 可能找不到您在 DOM 中搜索的元素之一 wait.until(EC.presence_of_element_located((By.ID,"username"))).send_keys("nocsud") wait.until(EC.presence_of_element_located((By.ID,"value"))).send_keys("noc_sud10")

    尝试检查“值”或“用户名”是否是 ID 或名称

    【讨论】:

    • 感谢您的回复,所以当我将参数更改为交互式时,我现在看到了问题,这是因为 chrome 认为该网站不安全,而现在的问题是如何绕过不安全的页面
    • 你应该点击advance,然后点击continue to unsafe page,类似的,你也可以使用selenium。
    猜你喜欢
    • 1970-01-01
    • 2021-03-25
    • 1970-01-01
    • 2021-06-02
    • 1970-01-01
    • 1970-01-01
    • 2021-10-15
    • 2021-03-24
    • 2015-09-18
    相关资源
    最近更新 更多