Getting web page throught a proxy (squid)

Mark Nottingham mnot at mnot.net
Tue Mar 21 21:44:37 EST 2000


ICP is for communication between proxies; normally, you can't fetch objects
through it; you'd want to use HTTP for that.

(small objects can be sent through ICP, but only very small ones).

If you're actually interested in an ICP module, tell me, maybe we can
work something up.


Cheers,


On Wed, Mar 22, 2000 at 01:22:29PM +1100, Steven Adams wrote:
> Jean-Paul ROUMIAN wrote:
> > 
> > Hello,
> > 
> > I try to get a web page,from  behind a proxy (squid) which uses the ICP
> > protocol.
> > Is there a module that can do that (httplib can't as far as I know) ?
> > 
> > (I need also  a ssl-connection, but I've found patches for this)
> > 
> > Any pointers ?
> > 
> > Jean-Paul ROUMIAN
> 
> Hi, 
> 
> I had to had to do exactly this, didn't need ssl though,
> here's a quick script that gets a webpage via proxy, and prints it out
> to screen (not too useful, but its only an example :-)
> --code--
> 
> import httplib
> PROXY = 'yourproxyname:yourproxyport' 
> URL='http://www.some.server/somefile.html'
> 
> h = httplib.HTTP(PROXY)
> h.putrequest('GET',URL)
> h.putheader('Accept','text/html')
> h.endheaders()
> 
> errcode,errmsg,headers = h.getreply()
> print errcode
> 
> file = h.getfile()
> data = file.read()
> file.close()
> print data
> 
> --code--
> 
> OK, so it ain't pretty, and it doesn't check that the errorcode is 200
> before getting file.
> but that was how I realised it was SQUID running as proxy.
> 
> hope that helps
> 
> Steven
> -- 
> http://www.python.org/mailman/listinfo/python-list

-- 
Mark Nottingham
http://www.mnot.net/




More information about the Python-list mailing list