12306Python
12306Python copied to clipboard
你好,这个程序为什么刷新到90次左右的时候就会终止?
提示信息: message: element not visible <Session info:.............> <Driver info:.................>
是因为查询按钮需要一定的时间才能渲染出现,通信过程中出现阻塞导致该按钮没有渲染出现, 建议使用try进行规避,避免因为阻塞造成抢票变慢,相关函数:specifyTrainNo 修改替换(有些乱):
def specifyTrainNo(self):
<code>
def specifyTrainNo(self):
count=0
while self.driver.url == self.ticket_url:
# 勾选车次类型,发车时间
self.searchMore();
sleep(0.05)
try:
self.driver.find_by_text(u"查询").click()
except Exception as e:
print(e)
print('未加载成功,重新循环')
continue
count += 1
print(u"循环点击查询... 第 %s 次" % count)
try:
self.driver.find_by_text(u"预订")[self.order - 1].click()
sleep(0.3)
except Exception as e:
print(e)
print(u"还没开始预订")
continue `