from selenium import webdriver
import time
data = {
'url' : 'https://pan.baidu.com/',
'enter_elem_id' : 'TANGRAM__PSP_4__footerULoginBtn',
'username_elem_id': 'TANGRAM__PSP_4__userName',
'password_elem_id': 'TANGRAM__PSP_4__password',
'submit_elem_id' : 'TANGRAM__PSP_4__submit',
'username' : 'xxx',
'password' : 'xxx',
}
# 下载chromedriver
# 放在chrome.exe父级目录下
# 将父级目录添加至环境变量
brower = webdriver.Chrome()
# 打开登录界面
brower.maximize_window()
brower.get(data['url'])
time.sleep(2)
enter_elem = brower.find_element_by_id(data['enter_elem_id'])
enter_elem.click()
# 登录
username_elem = brower.find_element_by_id(data['username_elem_id'])
password_elem = brower.find_element_by_id(data['password_elem_id'])
submit_elem = brower.find_element_by_id(data['submit_elem_id'])
time.sleep(2)
username_elem.send_keys(data['username'])
time.sleep(2)
password_elem.send_keys(data['password'])
time.sleep(2)
submit_elem.click()