fail to grep the "Server:" string line in headers

printf printf at hongkong.com
Wed Nov 21 18:37:16 EST 2001


Help
     I would like to grep the string after "Server:" in the headers. Any 
one can help me?

     I think I need get the string of headers, then put to search in 
"re", and grep the ...

     And is there any way to "grep" words in python?


class collectInfo:
         def __init__(self, _host):
                 self.host = _host
         def getServerName(self):
                 h = httplib.HTTP(self.host)
                 h.putrequest('GET', '/')
                 h.putheader('Accept', 'text/html')
                 h.putheader('Accept', 'text/plain')
                 h.endheaders()
                 errcode, errmsg, headers = h.getreply()
		print headers

                 p=re.compile('Server:') #wrong, why?
                 print p.search(hearders).span()#wrong 
                          why?




More information about the Python-list mailing list