什么介绍啊,背景啊我就省了,我只知道我需要一个能帮我抢到火车票的东西。那我刚学了python能不能实现呢?百度找资料并总结,我初步写出了如下代码:
from selenium import webdriver
import time
from selenium.webdriver.common.action_chains import ActionChains
def main():
login_text()
search_ticket()
book_ticket()
def login_text():
d.get(url)
d.implicitly_wait(30)
#登陆账号
username_ele = d.find_element_by_id('username')
username_ele.clear()
username_ele.send_keys(username)
#登陆密码
pwd_ele = d.find_element_by_id('password')
pwd_ele.clear()
pwd_ele.send_keys(pwd)
while True: #手动进行图片验证,并登录
curpage_url = d.current_url
if curpage_url != url:
if curpage_url[:-1] != url:
print('.......登陆成功........')
break
else:
time.sleep(3)
print('--------->等待用户进行图片验证')
def search_ticke