[Tutor] Passing HTTP commands through Telnet using Python for web site testing?
kent37 at tds.net
Thu Nov 17 13:57:31 CET 2005
> So far this is what I have come up with doing some research.
> import urllib
> for line in urllib.urlopen('http://mywebsit.com/folder/folder/test.asp'):
> if '400 Bad Request' in line:
> text_file = open("mysite.log", "a")
You are counting on the HTTP status code being part of the body of the response. This will depend on the details of the server. Better is to look at the actual HTTP status. Here is an example of retrieving a page with urllib2 and capturing HTTP status codes:
More information about the Tutor