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")
评论列表
文章目录