| 50 | break |
| 51 | |
| 52 | def start(self): |
| 53 | self.driver = Browser(driver_name=self.driver_name,executable_path=self.executable_path) |
| 54 | self.driver.driver.set_window_size(1400, 1000) |
| 55 | self.login() |
| 56 | # sleep(1) |
| 57 | self.driver.visit(self.ticket_url) |
| 58 | try: |
| 59 | print(u"购票页面开始...") |
| 60 | # sleep(1) |
| 61 | # 加载查询信息 |
| 62 | self.driver.cookies.add({"_jc_save_fromStation": self.starts}) |
| 63 | self.driver.cookies.add({"_jc_save_toStation": self.ends}) |
| 64 | self.driver.cookies.add({"_jc_save_fromDate": self.dtime}) |
| 65 | |
| 66 | self.driver.reload() |
| 67 | |
| 68 | count = 0 |
| 69 | if self.order != 0: |
| 70 | while self.driver.url == self.ticket_url: |
| 71 | self.driver.find_by_text(u"查询").click() |
| 72 | count += 1 |
| 73 | print(u"循环点击查询... 第 %s 次" % count) |
| 74 | # sleep(1) |
| 75 | try: |
| 76 | self.driver.find_by_text(u"预订")[self.order - 1].click() |
| 77 | except Exception as e: |
| 78 | print(e) |
| 79 | print(u"还没开始预订") |
| 80 | continue |
| 81 | else: |
| 82 | while self.driver.url == self.ticket_url: |
| 83 | self.driver.find_by_text(u"查询").click() |
| 84 | count += 1 |
| 85 | print(u"循环点击查询... 第 %s 次" % count) |
| 86 | # sleep(0.8) |
| 87 | try: |
| 88 | for i in self.driver.find_by_text(u"预订"): |
| 89 | i.click() |
| 90 | sleep(1) |
| 91 | except Exception as e: |
| 92 | print(e) |
| 93 | print(u"还没开始预订 %s" % count) |
| 94 | continue |
| 95 | print(u"开始预订...") |
| 96 | # sleep(3) |
| 97 | # self.driver.reload() |
| 98 | sleep(1) |
| 99 | print(u'开始选择用户...') |
| 100 | for user in self.users: |
| 101 | self.driver.find_by_text(user).last.click() |
| 102 | |
| 103 | print(u"提交订单...") |
| 104 | sleep(1) |
| 105 | self.driver.find_by_text(self.pz).click() |
| 106 | self.driver.find_by_id('').select(self.pz) |
| 107 | # sleep(1) |
| 108 | self.driver.find_by_text(self.xb).click() |
| 109 | sleep(1) |