selenium
自动登录百度
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('https://www.baidu.com')
import time
time.sleep(1)
driver.maximize_window()
time.sleep(1)
# 百度登录
driver.find_element_by_xpath('//div/a[8]').click()
time.sleep(3)
# 切换登录方式
driver.find_elements_by_css_selector('p.tang-pass-footerBarULogin')[0].click()
time.sleep(3)
# 找到并输入账号<input id="TANGRAM__PSP_10__userName">
driver.find_element_by_id('TANGRAM__PSP_10__userName').send_keys('账号')
time.sleep(1)
# 找到并输入密码<input id="TANGRAM__PSP_10__password">
driver.find_element_by_id('TANGRAM__PSP_10__password').send_keys('密码')
time.sleep(1)
# 找到并点击登录 <input id="TANGRAM__PSP_10__submit">
driver.find_element_by_id('TANGRAM__PSP_10__submit').click()
time.sleep(5)
# 关闭
driver.close()