Python Selenium预约驾校系统

以下代码专用于特定驾校系统预约,无普适性,了解Selenium功能详情参考链接

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import os
chromedriver = "chromedriver.exe"
os.environ["webdriver.chrome.driver"] = chromedriver
browser = webdriver.Chrome(chromedriver)
url1 = "http://yyyxjtdjx.ay001.net/NMobile/mLogin.htm"
browser.get(url1)

# 输入账号
inputElement = browser.find_element_by_id("txtUser")
inputElement.send_keys("00000000000000000000")
# 输入密码
inputElement = browser.find_element_by_id("txtPassWD")
inputElement.send_keys("000000000")
#登录
browser.find_element_by_id("ckbremember").click()
browser.find_element_by_id("btnLogin").click()

#跳转第二个页面
url2 ="http://yyyxjtdjx.ay001.net/NMobile/page/time.html?version=20160927" 
browser.get(url2)
browser.find_element_by_id("coachname").send_keys("XXX")
browser.find_element_by_id("btnSearch").click()
#选定预约信息
info = browser.find_element_by_xpath("//a[@starttime='07:00' and @ordercoach='XXX']")
text = info.get_attribute('isenble')
if(text=="不可用"):
	print(text)
elif(text=="已满"):
	print(text)
else:
	info.click()
#退出webdriver
browser.quit()

你可能感兴趣的:(【Project】,爬虫,搜索引擎,java爬虫程序,爬虫搜索,关键字搜索,selenium)