selenium+webservice进行百度登录

from selenium import webdriver
import time

driver = webdriver.Chrome()
driver.get("https://www.baidu.com/")


#点击登录链接
driver.find_element_by_xpath('//div[@id="u1"]//a[@name="tj_login"]').click()
time.sleep(3)
#通过第二次定位找到用户名登录
driver.find_element_by_class_name("tang-pass-footerBar").find_element_by_id("TANGRAM__PSP_10__footerULoginBtn").click()
time.sleep(5)
#输入用户名和密码
username = driver.find_element_by_id("TANGRAM__PSP_10__userNameWrapper").find_element_by_name("userName").send_keys("*****")
password = driver.find_element_by_id("TANGRAM__PSP_10__passwordWrapper").find_element_by_name("password").send_keys("******")
driver.find_element_by_id("TANGRAM__PSP_10__submit").click()
time.sleep(5)


driver.quit()

转载于:https://www.cnblogs.com/xiaohanzi/p/10001541.html

你可能感兴趣的:(selenium+webservice进行百度登录)