selenium_scholar.py 文件源码

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

项目:snowballing 作者: JoaoFelipe 项目源码 文件源码
def check_captcha(driver, condition):
    """ Check if it expects a captcha """
    captcha = driver.find_elements_by_css_selector("#captcha")
    captcha += driver.find_elements_by_css_selector("#gs_captcha_f")
    captcha += driver.find_elements_by_css_selector("#g-recaptcha")
    captcha += driver.find_elements_by_css_selector("#recaptcha")
    while captcha:
        print("Ops. It requires a captcha!")
        print("If you filled in the browser, type '<ok>' here.")
        inp = input("Captcha: ")
        if inp == "<ok>":
            break
        captcha[0].send_keys(inp)
        captcha[0].send_keys(Keys.RETURN)
        try:
            if condition:
                wait_for(driver, condition)
            break
        except TimeoutException:
            captcha = driver.find_elements_by_css_selector("#captcha")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号