Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > can httplib.HTTPConnection use proxy?

Reply
Thread Tools

can httplib.HTTPConnection use proxy?

 
 
JuHui
Guest
Posts: n/a
 
      03-16-2006
how to use httplib.HTTPConnection with http proxy?

 
Reply With Quote
 
 
 
 
robert
Guest
Posts: n/a
 
      03-16-2006
JuHui wrote:

> how to use httplib.HTTPConnection with http proxy?
>


simply connect to the proxy? - and ask using the full url and original
Host: - for HTTPS do a CONNECT <host>.

Robert
 
Reply With Quote
 
 
 
 
JuHui
Guest
Posts: n/a
 
      03-16-2006
sorry, would you please give a sample code?
I want to use HTTPConnection to get a html page content via a http
proxy.
thanks.

 
Reply With Quote
 
adam
Guest
Posts: n/a
 
      03-16-2006
>>> import httplib
>>> h = httplib.HTTPConnection("www.google.ca")
>>> h.connect()

Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python24\lib\httplib.py", line 627, in connect
raise socket.error, msg
error: (10061, 'Connection refused')
>>> h2 = httplib.HTTPConnection("my.proxy.host", "my.proxy.port")
>>> h2.connect()
>>> h2.request("GET", "http://www.google.ca")
>>> resp = h2.getresponse()
>>> page = resp.read()


 
Reply With Quote
 
robert
Guest
Posts: n/a
 
      03-17-2006
JuHui wrote:

> sorry, would you please give a sample code?
> I want to use HTTPConnection to get a html page content via a http
> proxy.
> thanks.
>


-> adam

and maybe you just want plain GET/POST. use urllib

>>> url='http://www.google.ca'
>>> urllib.FancyURLopener(proxies={'http':'http://vs:3128'}).open( url

).read()
'<html><head><meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1"><title>Google</title><style><!--\nbody,td,a,p,.h{font-family:arial,sans-serif;}\n.h{font-size:
20px....



Robert


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
If I use the WAP add-on, can I not use GridView paging and sorting? Chris S ASP .Net 0 12-13-2006 10:03 PM
Do U use >>>>>perl -e 'use re debug;/REGEX/' so U can help?? robertospara Perl Misc 14 12-10-2006 10:45 AM
How can I use switch -s and 'use strict' at the same time Ting Wang Perl Misc 5 10-06-2005 02:03 PM
Can I use use Microsoft Masked Edit Control in ASP.NET web form =?Utf-8?B?ZGF2aWQ=?= ASP .Net 1 04-19-2005 01:12 AM
Can I use XPath or something to a remote Mac or Linux box and just query an xml file, not using web services and use encyrption? jake ASP .Net 0 07-06-2004 02:16 PM



Advertisments