Put the try/except block inside the for statement to avoid breaking the entire script when encountering a 404 error