From 9be375de9eb6f4820eeff49f42ecee191487b9d8 Mon Sep 17 00:00:00 2001 From: yoshiko2 Date: Tue, 19 Apr 2022 00:00:28 +0800 Subject: [PATCH] The crawler result can be Dict or Str loaded by JSON --- WebCrawler/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/WebCrawler/__init__.py b/WebCrawler/__init__.py index 5c058e4..0e7ae12 100644 --- a/WebCrawler/__init__.py +++ b/WebCrawler/__init__.py @@ -134,7 +134,10 @@ def get_data_from_json(file_number, oCC): for source in sources: if conf.debug() == True: print('[+]select', source) - json_data = json.loads(pool.apply_async(func_mapping[source], (file_number,)).get()) + try: + json_data = json.loads(pool.apply_async(func_mapping[source], (file_number,)).get()) + except: + json_data = pool.apply_async(func_mapping[source], (file_number,)).get() # if any service return a valid return, break if get_data_state(json_data): print(f"[+]Find movie [{file_number}] metadata on website '{source}'") @@ -146,7 +149,10 @@ def get_data_from_json(file_number, oCC): try: if conf.debug() == True: print('[+]select', source) - json_data = json.loads(func_mapping[source](file_number)) + try: + json_data = json.loads(func_mapping[source](file_number)) + except: + json_data = func_mapping[source](file_number) # if any service return a valid return, break if get_data_state(json_data): print(f"[+]Find movie [{file_number}] metadata on website '{source}'")