由python的selenium来获取页面元素的一些方法,如获取,擦除,写入等。比较有借鉴性。获取网页ID元素还要继续巩固一下,可能存在找ID找错的情况。
#!usr/bin/env python
#_*_ coding:utf-8 _*_from selenium import webdriver
import time,sys,os
driver = webdriver.Chrome()
# 主路由 IP地址
ip2 = "192.168.3.1"
def print_current_time():
current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
return current_time
driver.get("http://192.168.3.1")
time.sleep(3)
login = driver.find_element_by_id("userpassword")
login.click()
login.send_keys("12345678")
driver.find_element_by_id("loginbtn").click()