selenium模拟登录csdn,可以输入用户名和密码,但是验证码还没有解决:
import selenium import selenium.webdriver import selenium.webdriver.common.keys import time driver = selenium.webdriver.Chrome(executable_path=r"C:UsersAdministratorAppDataLocalGoogleChromeApplicationchromedriver.exe") driver.get("https://passport.csdn.net/login?code=public") time.sleep(5) elem=driver.find_element_by_id("all") elem.send_keys("用户名") time.sleep(3) elem=driver.find_element_by_id("password") elem.send_keys("密码") time.sleep(5) elem.send_keys(selenium.webdriver.common.keys.Keys.RETURN) #RETURN 键盘enter键 time.sleep(15) print(driver.page_source) driver.close()