12306Python icon indicating copy to clipboard operation
12306Python copied to clipboard

你好,这个程序为什么刷新到90次左右的时候就会终止?

Open Allen-Liang opened this issue 8 years ago • 1 comments

提示信息: message: element not visible <Session info:.............> <Driver info:.................>

Allen-Liang avatar Jan 23 '18 12:01 Allen-Liang

是因为查询按钮需要一定的时间才能渲染出现,通信过程中出现阻塞导致该按钮没有渲染出现, 建议使用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 `

timegambler avatar Dec 13 '19 03:12 timegambler