Skip to content

Commit

Permalink
抢购成功后程序结束
Browse files Browse the repository at this point in the history
  • Loading branch information
huanghyw committed Dec 13, 2020
1 parent e051a80 commit e253f51
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions jd_spider_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def seckill(self):
"""
self.__seckill()

def system_exit(self):
sys.exit(1)

def wait_some_time(self):
time.sleep(random.randint(100, 300) / 1000)

Expand Down Expand Up @@ -67,7 +70,8 @@ def __seckill(self):
self.request_seckill_url()
while True:
self.request_seckill_checkout_page()
self.submit_seckill_order()
if self.submit_seckill_order():
self.system_exit()
except Exception as e:
logger.info('抢购发生异常,稍后继续执行!', e)
self.wait_some_time()
Expand All @@ -94,7 +98,7 @@ def login(self):
logger.info('第【%s】次失败请重新获取cookie', flag)
time.sleep(1)
continue
sys.exit(1)
self.system_exit()

def make_reserve(self):
"""商品预约"""
Expand Down

0 comments on commit e253f51

Please sign in to comment.