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__':