请指教一下,豆瓣的元素submit信息如图:
代码如下:
click、ENTER、RETURN、SPACE统统没用
from selenium import webdriver # 导入seleniumfrom selenium.webdriver.common.keys import Keysdef loginZhihu(): loginurl = 'https://accounts.douban.com/login' driver = webdriver.Chrome("C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe") driver.get(loginurl) driver.find_element_by_name('form_email').clear() driver.find_element_by_name('form_email').send_keys(u'5467878878') driver.find_element_by_name('form_password').clear() driver.find_element_by_name('form_password').send_keys(u'454354543543') captcha = driver.find_element_by_id('captcha_image') submit = driver.find_element_by_css_selector('input[class="bn-submit"]') if captcha: captcha_field = driver.find_element_by_id('captcha_field') text = input("请输入验证码:") captcha_field.send_keys(text) submit.send_keys(Keys.RETURN) else: submit.send_keys(Keys.RETURN)
九州编程
相关分类