def boot(): if global_config.getboolean(CMD_SECTION, 'aps'): datetime_obj = datetime.datetime.strptime(buy_time, '%Y-%m-%d %H:%M:%S.%f') # 设定时间的前两分钟再开启 ass。因为里面通过轮训的逻辑来执行定时操作。会消耗cpu。通过定时调度减缓一点消耗。 # 先不修改简单用用。看看效果再说。之后考虑重写逻辑全调度器。主要还是考虑精度问题 run_date = datetime_obj + datetime.timedelta(minutes=-5) scheduler = BlockingScheduler() scheduler.add_job(boot_ass, 'date', run_date=run_date, id='boot_ass') scheduler.start() else: boot_ass()
def __init__(self): use_random_ua = global_config.getboolean('config', 'random_useragent') self.user_agent = DEFAULT_USER_AGENT if not use_random_ua else get_random_useragent( ) self.headers = {'User-Agent': self.user_agent} self.is_login = False self.nick_name = '' ################## self.eid = global_config.get('config', 'eid') self.fp = global_config.get('config', 'fp') self.track_id = global_config.get('config', 'track_id') self.item_cat = dict() self.item_vender_ids = dict() # 记录商家id self.timeout = float( global_config.get('config', 'timeout') or DEFAULT_TIMEOUT) self.send_message = global_config.getboolean('messenger', 'enable') self.messenger = Messenger(global_config.get( 'messenger', 'sckey')) if self.send_message else None self.sess = requests.session()
def __init__(self): use_random_ua = global_config.getboolean('config', 'random_useragent') self.user_agent = DEFAULT_USER_AGENT if not use_random_ua else get_random_useragent()
def __init__(self): self.header = DEFAULT_HEADER self.send_message = global_config.getboolean('messenger', 'enable') self.messenger = Messenger(global_config.get( 'messenger', 'sckey')) if self.send_message else None
#!/usr/bin/env python # -*- coding:utf-8 -*- from config import global_config from jd_assistant import Assistant TESTING = False # 设为True测试下单功能是否正常 if global_config.getboolean('notification', 'enabled'): from notification import telegram_success_notify_callback notify = True else: notify = False if __name__ == '__main__': """ 重要提示:此处为示例代码之一,请移步下面的链接查看使用教程👇 https://github.com/tychxn/jd-assistant/wiki/1.-%E4%BA%AC%E4%B8%9C%E6%8A%A2%E8%B4%AD%E5%8A%A9%E6%89%8B%E7%94%A8%E6%B3%95 """ if not TESTING: sku_ids = [ 100006784140, 100006784144, 100010222606, 100006248177, 1835968, 1835967, 100005151507, 100005818743, 100002690344, 100010638508, 100009445348, 100009441994, 100009109410, 100006248247, 4642656, 100009130434, 7498167, 51137726169, 6046611, 59959871345 ] skus = ','.join(f'{i}:1' for i in sku_ids) with Assistant() as asst: asst.login_by_QRcode() # 扫码登陆 asst.clear_cart() # asst.exec_reserve_seckill_by_time(sku_id="100009083498", buy_time="2019-11-10 22:42:30.000") asst.buy_item_in_stock(
logger.info("已自动计算日期\t预约日期:%s\t下单时间:%s", enterDate, begin_time) return enterDate, begin_time if __name__ == '__main__': sub = Subway() lineName = global_config.get("config", "line") stationName = global_config.get("config", "station") enterDate = global_config.get("config", "date_slot") timeSlot = global_config.get("config", "time_slot") begin_time = global_config.get("config", "begin_time") retry_times = int(global_config.get("config", "retry_times"), 10) retry_inter = int(global_config.get("config", "interval"), 10) autoRun = global_config.getboolean('control', 'auto_run') if autoRun: enterDate, begin_time = autoGetAppointDateParam(begin_time) while True: lastAppointResult = sub.make_reserve_by_time(lineName, stationName, enterDate, timeSlot, begin_time, retry_times, retry_inter) if lastAppointResult: logger.info("预约成功:%s %s %s %s", lineName, stationName, enterDate, timeSlot) else: logger.error("预约失败") if autoRun: logger.info("自动执行已开启,将自动设置下一次预约时间")