Use more specific exception handling

This commit is contained in:
Thomas Wade 2020-04-21 17:01:31 +09:30
parent 345c95a477
commit 15b46d2ac1

View File

@ -72,7 +72,7 @@ class User:
try: try:
next_page_button = soup.select('.submission-list form button[type=submit]')[0] next_page_button = soup.select('.submission-list form button[type=submit]')[0]
next_page_url = FAAPI.FA_BASE_URL + next_page_button.parent().get('action') next_page_url = FAAPI.FA_BASE_URL + next_page_button.parent().get('action')
except: except IndexError:
# No next page, null the url to break the loop # No next page, null the url to break the loop
next_page_url = None next_page_url = None
@ -93,7 +93,7 @@ class User:
try: try:
next_page_button = soup.select('.pagination a.button:last-child')[0] next_page_button = soup.select('.pagination a.button:last-child')[0]
next_page_url = FAAPI.FA_BASE_URL + next_page_button.get('href') next_page_url = FAAPI.FA_BASE_URL + next_page_button.get('href')
except: except IndexError:
# No next page, null the url to break the loop # No next page, null the url to break the loop
next_page_url = None next_page_url = None