#!/usr/bin/python3 #coding:utf-8 from selenium import webdriver #下面填入用户名以及密码 up={"ue":"admin","pd":"[email protected]"} chromedriver = "D:\\chromedriver.exe" chrome=webdriver.Chrome(chromedriver) chrome.get(url="http://www.ceshi.com/") # chrome.find_element_by_xpath("//*[@id=\"loginDiv\"]/div/div[1]/div/div[2]/a").click() User=chrome.find_element_by_id("username") User.clear() User.send_keys(jd_up["ue"]) Passwd=chrome.find_element_by_id("userPassword") Passwd.clear() Passwd.send_keys(jd_up["pd"]) chrome.find_element_by_id("loginbtn").click() chrome.get(url="http://www.ceshi.com/url") chrome.quit
chromedriver需要安装
http://chromedriver.storage.googleapis.com/index.html下载对应的版本