how to validate a proxy is alive?

robert no-spam at no-spam-no-spam.com
Fri Mar 10 14:15:50 CET 2006


JuHui wrote:
> I want to get a html page content via a http proxy.
> befor this, I want to check the proxy. how to validate it?
> thanks
> 

most simple by a socket-connect / error if non-existing:

 >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 >>> s.connect(('nonexisting-proxy-server',3129))
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
   File "<string>", line 1, in connect
error: (10061, 'Connection refused')
 >>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 >>> s.connect(('existing-proxy-server',3128))
 >>> 1
1
 >>>



Robert



More information about the Python-list mailing list