Python Selenium预约驾校系统
程序员文章站
2022-04-19 12:29:15
以下代码专用于特定驾校系统预约,无普适性,了解Selenium功能详情参考链接from selenium import webdriverfrom selenium.webdriver.common.keys import Keysimport oschromedriver = "chromedriver.exe"os.environ["webdriver.chrome.driver"] = chromedriverbrowser = webdriver.Chrome(chromedriver)...
以下代码专用于特定驾校系统预约,无普适性,了解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()
本文地址:https://blog.csdn.net/zhr_the_great/article/details/107163679