I wrote a program in Python yesterday that checks hundreds of URLs for validity (that they won’t 404 mainly) but currently when my program runs into a URL that is not valid it throws many exceptions and then crashes. I am using urllib.urlopen to visit the links. Is there anyway for my program to ignore these exceptions and continue running but log somewhere the lines of code that caused the problem?
Share
You can use the Logger.exception() method. For example :
That will display the traceback of the url that raise exceptions, and still continue to test the other URL.