472,352 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Help Tracing urllib2 Error, Please?

Since it seems I have a "unique" problem, I wonder if anyone could
point me in the general/right direction for tracking down the issue
and resolving it myself.

See my prior post @ http://groups.google.com/group/comp....6b55161?hl=en#
for more info. (Python 2.5.2 on Win XP 64 ==>Squid Proxy requiring
Authentication ==>Internet not working.)

I've looked the urllib2 source over, but am having trouble following
it. As previously mentioned, urllib2 initiates the request, Squid
replies "407 error" that auth's required, and then urllib2 just stops,
throwing error 407.

Any though(s) on what to check out?

It's frustrating (to say the least) that it seems so many are
successfully accomplishing this task, and all's working perfectly for
them, but I'm failing miserably.

Would any quotes viewed in the HTTP traffic help? (Wireshark shows
all! :) I don't even know what other info could help.

Any info to get about Squid's configuration that might make it "non
standard" in a way that could cause my problem? Any question(s) I
should ask my Net Admin to relay info to you all?
As always, any/all help greatly appreciated. Thanks! :)

-Larry
Jul 19 '08 #1
1 1895
Larry Hale <la*****@hotmail.comwrites:
Since it seems I have a "unique" problem, I wonder if anyone could
point me in the general/right direction for tracking down the issue
and resolving it myself.

See my prior post @ http://groups.google.com/group/comp....6b55161?hl=en#
for more info. (Python 2.5.2 on Win XP 64 ==>Squid Proxy requiring
Authentication ==>Internet not working.)

I've looked the urllib2 source over, but am having trouble following
it. As previously mentioned, urllib2 initiates the request, Squid
replies "407 error" that auth's required, and then urllib2 just stops,
throwing error 407.

Any though(s) on what to check out?

It's frustrating (to say the least) that it seems so many are
successfully accomplishing this task, and all's working perfectly for
them, but I'm failing miserably.

Would any quotes viewed in the HTTP traffic help? (Wireshark shows
all! :) I don't even know what other info could help.

Any info to get about Squid's configuration that might make it "non
standard" in a way that could cause my problem? Any question(s) I
should ask my Net Admin to relay info to you all?
Maybe Squid is configured to not allow sending authentication
directly in URI. Or maybe there is only digest scheme allowed.
Try this:

def getopener(proxy=None, digest=False):
opener = urllib2.build_opener(urllib2.HTTPHandler)
if proxy:
passwd_mgr = urllib2.HTTPPasswordMgr()
passwd_mgr.add_password(None, 'http://localhost:3128', 'user', 'password')

if digest:
proxy_support = urllib2.ProxyDigestAuthHandler(passwd_mgr)
else:
proxy_support = urllib2.ProxyBasicAuthHandler(passwd_mgr)
opener.add_handler(proxy_support)
return opener
def fetchurl(url, opener):
f = opener.open(url)
data = f.read()
f.close()
return data

print fetchurl('http://www.python.org', getopener('127.0.0.1:3128'))
print fetchurl('http://www.python.org', getopener('127.0.0.1:3128', digest=True))

HTH,
Rob
Jul 20 '08 #2

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

Similar topics

4
by: bmiras | last post by:
I've got a problem using urllib2 to get a web page. I'm going through a proxy using user/password authentification and i'm trying to get a page...
2
by: John F Dutcher | last post by:
Can anyone comment on why the code shown in the Python error is in some way incorrect...or is there a problem with Python on my hoster's site ??...
1
by: Fuzzyman | last post by:
I'm trying to do Basic authentication using urllib2 and HTTPPasswordMgr Objects. According to my understanding I ought to perform the following...
0
by: jacob c. | last post by:
When I request a URL using urllib2, it appears that urllib2 always makes the request using HTTP 1.0, and not HTTP 1.1. I'm trying to use the...
2
by: Mark Delon | last post by:
Hi, i want to log via python script to https page: 'https://brokerjet.ecetra.com/at/' # But it does not work. I am using following...
1
by: est | last post by:
A simple py script import urllib2 req=urllib2.Request("http://www.google.com") req.set_proxy("127.0.0.1:1","http") print...
1
by: Magnus.Moraberg | last post by:
Hi, I have the following code - import urllib2 from BeautifulSoup import BeautifulSoup proxy_support =...
6
by: robean | last post by:
Hi everyone, I have a question about using urllib2. I like urllib2 better than urllib at least in part because it has more elaborate support...
2
by: silk.odyssey | last post by:
I am getting the following error trying to download an html page using urllib2. urllib2.HTTPError: HTTP Error 204: NoContent The url is of...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

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.