diff --git a/crawler.py b/crawler.py index f24eaeb..dcc639a 100644 --- a/crawler.py +++ b/crawler.py @@ -38,6 +38,7 @@ def main(args): with tqdm(total=max_len) as pbar: if args.start_page_number: pbar.update(data_number) + pbar.refresh() while data_number < max_len: pbar.set_description(f"Page number: {page_number}") @@ -64,6 +65,8 @@ def main(args): except Exception as e: print(e) save_data(f"./{args.output_file_name}-{args.type}.tsv", result_list) + except KeyboardInterrupt: + save_data(f"./{args.output_file_name}-{args.type}.tsv", result_list) save_data(f"./{args.output_file_name}-{args.type}.tsv", result_list)