#!/usr/bin/env python # -*- coding:utf-8 -*- from jd_assistant import Assistant 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 """ asst = Assistant() # 初始化 asst.login_by_QRcode() # 扫码登陆 asst.clear_cart() asst.exec_reserve_seckill_by_time(sku_id="100006047279", buy_time="2020-01-17 20:00:00.001") # 执行预约抢购 # 5个参数 # sku_id: 商品id # buy_time: 下单时间,例如:'2019-11-10 22:41:30.000' # retry: 抢购重复执行次数,可选参数,默认4次 # interval: 抢购执行间隔,可选参数,默认4秒 # num: 购买数量,可选参数,默认1个
#!/usr/bin/env python # -*- coding:utf-8 -*- from jd_assistant import Assistant if __name__ == '__main__': asst = Assistant() asst.login_by_QRcode() # 扫码登陆 asst.clear_cart() # 清空购物车 asst.add_item_to_cart(sku_id='1626336666') # 添加到购物车 # 3种订单提交方式: # 1.直接提交订单 # asst.submit_order() # 2.有货时提交订单 asst.submit_order_by_stock(sku_id='1626336666', area='1_2802_2821') # 监控的商品id和地址id # 3.定时提交订单 # asst.submit_order_by_time(buy_time='2018-10-19 00:00:00.500', retry=3, interval=5) asst.get_order_info(unpaid=False) # 查询未付款订单 """ 输出实例: [2018-10-19 02:38:58] 登录成功 [2018-10-19 02:38:58] 购物车清空成功 [2018-10-19 02:38:58] 1626336666已成功加入购物车 [2018-10-19 02:38:59] 1626336666有货了,正在提交订单…… [2018-10-19 02:38:59] 订单提交成功! 订单号:811545xxxxx ************************订单列表页查询************************ 订单号:811545xxxxx----下单时间:2018-10-19 02:38:59----商品列表:1626336666 x 1----订单状态:等待付款----总金额:89.90元----付款方式:在线支付 """
# 开始抢购 if buy_time: rand_msecond = random.randint(1, 9) * 1000 buy_time = buy_time + '.000' # buy_time = buy_time + "." + str(rand_msecond) else: print('获取抢购时间失败') buy_time = input("请输入抢购时间(2020-03-04 00:59:59.000):") asst.exec_reserve_seckill_by_time(sku_id=sku_id, buy_time=buy_time, retry=10, interval=1, num=1) # asst.exec_seckill_by_time(sku_ids=sku_id, buy_time=buy_time, retry=15, interval=0.2, num=1) elif model_type == '2': print("正常有货购买...") sku_ids = input("请输入一个或多个sku_id:") area = input("请输入area_id:") asst.buy_item_in_stock(sku_ids=sku_ids, area=area, wait_all=False, stock_interval=5) elif model_type == '3': print("正常定时购买...") sku_ids = input("请输入一个或多个sku_id:") buy_time = input("请输入定时购买时间(2020-03-04 00:59:59.000):") asst.clear_cart() # 清空购物车(可选) asst.add_item_to_cart(sku_ids=sku_ids) # 根据商品id添加购物车(可选) asst.submit_order_by_time(buy_time=buy_time, retry=10, interval=5) # 定时提交订单