Re: sockets

2006-01-20 Thread Allan Zhang
> >> the following code works perfectly >> import socket, sys >> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >> s.connect(("www.python.org", 80)) >> s.send("GET") here, You need to speak HTTP protocol. I would suggest to change s.send( "GET / HTTP/1.0\x0d\x0a\x0d\x0a" ) >> whi

Re: Parsing files -- pyparsing to the rescue?

2006-01-16 Thread Allan Zhang
Try this code = import re p = re.compile(r'([^<]*)<') s = open("file").read() m = re.search(p, s) if m: res = m.groups()[0] res = res.lstrip("\n") res = res.rstrip("\n") print res result: === %python parser.py Sys Data Sys-Data asdkData Data % Thanks Allan "rh0dium" <[EMAIL PROTECTED]>