473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

can httplib.HTTPConnection use proxy?

how to use httplib.HTTPConnection with http proxy?

Mar 16 '06 #1
4 11706
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
Mar 16 '06 #2
sorry, would you please give a sample code?
I want to use HTTPConnection to get a html page content via a http
proxy.
thanks.

Mar 16 '06 #3
>>> 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()


Mar 16 '06 #4
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
Mar 17 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: scummer | last post by:
Hi, I am having a problem with the httplib HTTPConnection object. While I can easily send requests that don't have any payload (ie. "get"), I encounter issues if I want to post xml data. If you...
0
by: Laszlo Zsolt Nagy | last post by:
Hello, This is from the docs, from section 11.6.1 (HTTPConnection Objects) HTTPConnection instances have the following methods: request( method, url]) The headers argument should be a...
2
by: spamsink42 | last post by:
this code h=httplib.HTTPConnection('euronext.com') h.request('GET', 'http://www.euronext.com/home/0,3766,1732,00.html') fails with this message File "httplib.py", line 532, in connect...
0
by: JuHui | last post by:
how to use httplib.HTTPConnection with http proxy?
5
by: scott | last post by:
Hello, From a shell script, I have used /usr/bin/curl to access a web site and pass a cookie (as required by the site). But, I can't seem to accomplish this task with Python. I would like to...
3
by: Mark rainess | last post by:
The program displays images from a motion jpeg webcam. (Motion jpeg is a bastardization of multi-part mime.) <http://wp.netscape.com/assist/net_sites/pushpull.html> It runs perfectly for about 4...
0
by: Dustin J. Mitchell | last post by:
I'm building an interface to Amazon's S3, using httplib. It uses a single object for multiple transactions. What's happening is this: HTTP PUT /unitest-temp-1161039691 HTTP/1.1 HTTP Date: Mon,...
11
by: Phoe6 | last post by:
Hi, The following piece of code works properly when my proxy password contains characters etc. But when my proxy password contained something like '|\/|' , the httplib incorrectly indentified it...
3
by: rhXX | last post by:
hi all, i'm using this tutorial example import httplib h = httplib.HTTP("www.python.org") h.putrequest('GET','/index.html') h.putheader('User-Agent','Lame Tutorial Code')...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.