from selenium import webdriver
import time
data = {
'url': 'http://10.0.0.1',
'login': 'loginBtn',
'telephone': 'telephone',
'auth_code': 'authCode',
'login_btn': 'loginBtn',
'phone': 'xxxxxxxxxxx',
'captcha': 'xxxx',
}
browser = webdriver.Chrome()
# 点击"网页联网"按钮
browser.maximize_window()
browser.get(data['url'])
time.sleep(2)
login_elem = browser.find_element_by_id(data['login'])
login_elem.click()
# 登录
telephone = browser.find_element_by_name(data['telephone'])
auth_code = browser.find_element_by_name(data['auth_code'])
login_btn = browser.find_element_by_id(data['login_btn'])
time.sleep(2)
telephone.send_keys(data['phone'])
time.sleep(2)
auth_code.send_keys(data['captcha'])
time.sleep(2)
login_btn.click()
# 放行操作
time.sleep(5)
refresh_js = 'location=document.body.querySelector(\'div[class=\"row back_c_ffffff padding_bottom_20\"] div a\');'
browser.execute_script(refresh_js)