[Tutor] Passing HTTP commands through Telnet using Python for website testing?

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

> Anyway, Can someone point me in the right direction on getting the Telnet
> working? Or if you have a better way to get what I am trying to do
> accomplished. Is there a Python Telnet module?

I think the urllib module will be easier.

Just open the url and read the output into a list. check the line and if
necessary write to the log file


import urllib as url
import time
logfile = open('log.txt','a;')  # append mode

page = url.open('www.whatever.com/wherever').read()
page = page.split()
if '404' in page[0]:  # will it be the first line?
   logfile.write('Whoops it went missing at: ' + 

Does that look like the kind of thing?

Alan G.

More information about the Tutor mailing list