from Book import Book from General import General from Notify import Output if __name__ == '__main__': method_name = '_Book_seat' cfg = General.get_config()[0] notify_type = cfg.get(method_name, 'notify_type') target_users = cfg.get(method_name, 'target_names').split(',') target_seats = cfg.get(method_name, 'target_seats').split(',') target_rooms = cfg.get(method_name, 'target_rooms').split(',') date = cfg.getint(method_name, 'date') output = Output() for i in range(min(len(target_rooms), len(target_seats), len(target_users))): book = Book(target_users[i]) book = book.prepare(target_rooms[i], target_seats[i], date) res = book.book() # while res != 1: # res = book.book()
from General import General from Notify import Output if __name__ == '__main__': method_name = '_Auto_book' cfg = General.get_config()[0] notify_type = cfg.get(method_name, 'notify_type') type = cfg.getint(method_name, 'type') target_name = cfg.get(method_name, 'target_name') target_room = cfg.get(method_name, 'target_room') target_seat = cfg.getint(method_name, 'target_seat') max_try_times = cfg.getint(method_name, 'max_try_times') output = Output() t = Time() while True: date = 0 if type in (1, 2) else 1 if type in (0, 1): t.time_control(type) # 时间控制 b = Book(target_name).prepare(target_room, target_seat, date) flag = -1 # 是否预约成功 cnt = 0 # 发送请求次数 while flag != 1 and cnt < max_try_times: flag = b.book() cnt += 1 # current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") # output.continuous_output(current_time) text = format('预约成功') output.final_output(text, notify_type)
# 若有可用座位 if len(query) != 0: # 判断是否为所指定座位 del_sid = [] for sid in range(len(target_seat)): if target_seat[sid] in query: seat = target_seat[sid] room_id = seat[0] seat_id = seat[1] text = format('%s-%s次车有余票,正在尝试下单,下单用户%s' % (room_id, seat_id, target_users[0])) output.continuous_output(text) account = Book(target_users[0]) account.prepare(room_id, seat_id, date) account.book() text = format('%s-%s次车,下单成功,下单用户%s' % (room_id, seat_id, target_users[0])) output.final_output(text, notify_type) output.continuous_output(text) # 删除该用户&预约座位&查询 del target_users[0] del_sid.append(sid) query.remove(seat) if not target_users: cur = -1 text = format('提醒:已无可用用户,即将退出!') output.continuous_output(text)
from Book import Book from General import General cfg = General.get_config()[0] if __name__ == '__main__': target_user = cfg.get('_Book_seat', 'target_name') book = Book(target_user) target_room = cfg.get('_Book_seat', 'target_room') target_seat = cfg.getint('_Book_seat', 'target_seat') date = cfg.getint('_Book_seat', 'date') book = book.prepare(target_room, target_seat, date) import time while True: book.book() time.sleep(3)
from Coupon import Coupon from Login import Login from Book import Book if __name__ == '__main__': config = open('config', 'r+') thor = config.readline() if not thor or thor == '': #登录获取thor(扫码登录) loginObj = Login() loginObj.login() thor = loginObj.get() config.write(thor) config.close() #根据商品的id快速下单 b = Book(thor) b.book('27752137726', 1) #根据券的id领取优惠券 c = Coupon(thor) c.getCoupon( 'a89a85ebee8296dc65bd776f4a1d414e4e224464bb14bd65f5e822c44ff2854868dffebfbaa256891583cb0c75b53605' )