Hi Paul, I am trying to extract HTTP response codes from a HTTP page send from a web server. Below is my test program. The program just hangs.
Thanks, Khoa ################################################## #!/usr/bin/python from pyparsing import ParseException, Dict, CharsNotIn, Group,Literal,Word,ZeroOrMore,OneOrMore, Suppress,nums,alphas,alphanums,printables,restOfLine data = """HTTP/1.1 200 OK body line some text here body line some text here HTTP/1.1 400 Bad request body line some text here body line some text here HTTP/1.1 500 Bad request body line some text here body line some text here """ print "=================" print data print "=================" HTTPVersion = (Literal("HTTP/1.1")).setResultsName("HTTPVersion") StatusCode = (Word(nums)).setResultsName("StatusCode") ReasonPhrase = restOfLine.setResultsName("ReasonPhrase") StatusLine = Group(HTTPVersion + StatusCode + ReasonPhrase) nonHTTP = ~Literal("HTTP/1.1") BodyLine = Group(nonHTTP + restOfLine) Response = OneOrMore(StatusLine + ZeroOrMore(BodyLine)) respFields = Response.parseString(data) print respFields -- http://mail.python.org/mailman/listinfo/python-list