diff --git a/main.py b/main.py index b7f6b3c..91c0dc7 100644 --- a/main.py +++ b/main.py @@ -33,6 +33,8 @@ def write_json(file_path, data): with open(file_path, "w", encoding="utf-8") as f: json.dump(data, f, ensure_ascii=False, indent=4) +atexit.register(lambda: write_json(OUTPUT_FILE, {"tweets": _results})) + async def main(): global _results api = API() # or API("path-to.db") – default is `accounts.db` @@ -63,7 +65,6 @@ async def main(): await asyncio.sleep(random.uniform(17, 31)) - atexit.register(lambda: write_json(OUTPUT_FILE, {"tweets": _results})) if __name__ == "__main__": asyncio.run(main()) \ No newline at end of file