I’m trying to write a script which will read a file containing some urls and then open a browser instance using mechanize module. I’m just wondering how I can do so if some url does not exist or if the server is unreachable.
For Example
import mechanize
br = mechanize.Browser()
b = br.open('http://192.168.1.30/index.php')
What I want to know is how I will get information from mechanize if 192.168.1.30 is unreachable or if http returns 404 Error.
Or Use Python requests library.
Sample code demonstrating it: