From 5933df16876a55164f448f7c3deac4051170eccf Mon Sep 17 00:00:00 2001 From: SoHyeonAn <46175598+sleepyeePanda@users.noreply.github.com> Date: Fri, 1 May 2020 19:01:40 +0900 Subject: [PATCH] fix: check if error exists in response data print error if error exists in the api response data(video_data_page) --- scraper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scraper.py b/scraper.py index f06eafd..7a2868f 100644 --- a/scraper.py +++ b/scraper.py @@ -108,6 +108,9 @@ def get_pages(country_code, next_page_token="&"): while next_page_token is not None: # A page of data i.e. a list of videos and all needed data video_data_page = api_request(next_page_token, country_code) + + if video_data_page.get('error'): + print(video_data_page['error']) # Get the next page token and build a string which can be injected into the request with it, unless it's None, # then let the whole thing be None so that the loop ends after this cycle @@ -151,4 +154,4 @@ def get_data(): output_dir = args.output_dir api_key, country_codes = setup(args.key_path, args.country_code_path) - get_data() \ No newline at end of file + get_data()