Dec-22-2022, 06:13 PM
This won't work because in the line
You could check if the list is empty
title = get_element(title_selector[0].text, 'Untitled') # Returns first element in title_selector if there is one; if IndexError returns 'Untitled'that is where the
IndexError
will be raised before it gets to the function as it is trying to index the listYou could check if the list is empty
if not title_selector: title = 'Untitled' else: title = whatever_you_want_to_do_instead