Skip to content

Commit

Permalink
购买时间优化
Browse files Browse the repository at this point in the history
  • Loading branch information
yuexiaohui committed Dec 29, 2020
1 parent 6d21eac commit 5aae82e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ fp = ""
# 已经是茅台的sku_id了
sku_id = 100012043978
# 设定时间 # 2020-12-09 10:00:00.100000
buy_time = 2020-12-22 09:59:59.500
# 修改成每天的几点几分几秒几毫秒
buy_time = 09:59:59.500
# 默认UA
DEFAULT_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
# 是否使用随机 useragent,默认为 false
Expand Down
8 changes: 7 additions & 1 deletion timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
class Timer(object):
def __init__(self, sleep_interval=0.5):
# '2018-09-28 22:45:50.000'
self.buy_time = datetime.strptime(global_config.getRaw('config','buy_time'), "%Y-%m-%d %H:%M:%S.%f")
# buy_time = 2020-12-22 09:59:59.500
buy_time_everyday = global_config.getRaw('config', 'buy_time').__str__()
localtime = time.localtime(time.time())
self.buy_time = datetime.strptime(
localtime.tm_year.__str__() + '-' + localtime.tm_mon.__str__() + '-' + localtime.tm_mday.__str__()
+ ' ' + buy_time_everyday,
"%Y-%m-%d %H:%M:%S.%f")
self.buy_time_ms = int(time.mktime(self.buy_time.timetuple()) * 1000.0 + self.buy_time.microsecond / 1000)
self.sleep_interval = sleep_interval

Expand Down

0 comments on commit 5aae82e

Please sign in to comment.