refactor: 保存每次请求到的最新消息 id
This commit is contained in:
parent
02a51c6bef
commit
bcbc299167
@ -129,8 +129,7 @@ def run(instance, access_token, fanfou_cookie, fanfou_token):
|
|||||||
# first time run
|
# first time run
|
||||||
posted_ids = []
|
posted_ids = []
|
||||||
# if file not exist, create it
|
# if file not exist, create it
|
||||||
with open('last_id.txt', 'a+') as f:
|
with open('last_id.txt', 'r') as f:
|
||||||
f.seek(0)
|
|
||||||
# read lines
|
# read lines
|
||||||
posted_ids = f.readlines()
|
posted_ids = f.readlines()
|
||||||
# remove \n
|
# remove \n
|
||||||
@ -164,6 +163,9 @@ def run(instance, access_token, fanfou_cookie, fanfou_token):
|
|||||||
if statuses:
|
if statuses:
|
||||||
min_id = statuses[-1]['id']
|
min_id = statuses[-1]['id']
|
||||||
else:
|
else:
|
||||||
|
if min_id:
|
||||||
|
with open('last_id.txt', 'a') as f:
|
||||||
|
f.write(str(min_id) + '\n')
|
||||||
min_id = None
|
min_id = None
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user