Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check if error exists in response data #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
get_data()