From bcbc299167f1bf20abe1df357c05bd9c8116f951 Mon Sep 17 00:00:00 2001 From: Ching Date: Tue, 26 Mar 2024 18:05:26 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=9D=E5=AD=98=E6=AF=8F?= =?UTF-8?q?=E6=AC=A1=E8=AF=B7=E6=B1=82=E5=88=B0=E7=9A=84=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E6=B6=88=E6=81=AF=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mas2ff2.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mas2ff2.py b/mas2ff2.py index ea468b7..7e053b2 100644 --- a/mas2ff2.py +++ b/mas2ff2.py @@ -129,8 +129,7 @@ def run(instance, access_token, fanfou_cookie, fanfou_token): # first time run posted_ids = [] # if file not exist, create it - with open('last_id.txt', 'a+') as f: - f.seek(0) + with open('last_id.txt', 'r') as f: # read lines posted_ids = f.readlines() # remove \n @@ -164,6 +163,9 @@ def run(instance, access_token, fanfou_cookie, fanfou_token): if statuses: min_id = statuses[-1]['id'] else: + if min_id: + with open('last_id.txt', 'a') as f: + f.write(str(min_id) + '\n') min_id = None if __name__ == '__main__':