【问题标题】:No such element exception. Unable to locate element in selenium python没有这样的元素例外。无法在 selenium python 中找到元素
【发布时间】:2021-11-06 00:03:22
【问题描述】:

我想在此页面https://www.archionweb.be/Public/Company/1930 上从https://www.archionweb.be/ 抓取电子邮件。

电子邮件在验证码中受到保护,因此想法是单击验证码然后提取电子邮件。但是每当我尝试点击验证码按钮(我同时使用了 XPath 和 CSS 选择器)时,都会出现异常:

“没有这样的元素:无法找到元素”

如果有人可以帮助我,请。

【问题讨论】:

    标签: python selenium web-scraping data-mining data-extraction


    【解决方案1】:

    由于即使在点击 I am not a Robot 之后我们也在自动化,它有时会再次重新验证码。能够使用以下代码单击复选框。

    from selenium import webdriver
    import time
    from selenium.webdriver.common.action_chains import ActionChains
    
    
    driver = webdriver.Chrome(executable_path="path to chromedriver.exe")
    driver.maximize_window()
    driver.implicitly_wait(30)
    driver.get("https://www.archionweb.be/Public/Company/1930")
    time.sleep(5)
    iframe = driver.find_element_by_xpath("//iframe[@title='reCAPTCHA']")
    driver.switch_to.frame(iframe)
    time.sleep(5)
    recaptcha = driver.find_element_by_class_name("recaptcha-checkbox-borderAnimation")
    driver.execute_script("arguments[0].scrollIntoView(true);",recaptcha)
    ActionChains(driver).move_to_element(recaptcha).click().perform()
    time.sleep(2)
    driver.switch_to.default_content()
    
    

    【讨论】:

      猜你喜欢
      • 2021-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多