[Tutor] Passing HTTP commands through Telnet using Python forweb site testing?

Alan Gauld alan.gauld at freenet.co.uk
Thu Nov 17 13:15:00 CET 2005


Looks like you pretty well figured it out.

for the timestamp there is the basic timemodule, the datetime module
or the extra module mxdatetime. Each more sophisticated than the last...

Alan G
----- Original Message ----- 
From: "Adisegna" <adisegna at gmail.com>
To: <tutor at python.org>
Sent: Thursday, November 17, 2005 4:13 AM
Subject: Re: [Tutor] Passing HTTP commands through Telnet using Python 
forweb site testing?


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")
text_file.writelines(line)
text_file.writelines("\n")
text_file.close()

This writes the to a new line each time the script is run. Now I have to
figure out an "if then else" to write the other possible error codes and
appending a timestamp followed by a space each time it runs.

Thanks



More information about the Tutor mailing list