473,799 Members | 2,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1994
Larry Hale <la*****@hotmai l.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_o pener(urllib2.H TTPHandler)
if proxy:
passwd_mgr = urllib2.HTTPPas swordMgr()
passwd_mgr.add_ password(None, 'http://localhost:3128' , 'user', 'password')

if digest:
proxy_support = urllib2.ProxyDi gestAuthHandler (passwd_mgr)
else:
proxy_support = urllib2.ProxyBa sicAuthHandler( passwd_mgr)
opener.add_hand ler(proxy_suppo rt)
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
4463
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 asking for a HTTP authentification. And I'm using python 2.3 Here is an exemple of the piece of code I use: import urllib2 #Proxy handler proxy_handler = urllib2.ProxyHandler({"http" :
2
6120
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 ?? The highlites don't seem to show here...but line #80 and line # 38 are the first line offenders. --> --> -->
1
3773
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 simple sequence (except it doesn't work). Can someone cast their eyes over it and see what I'm doing wrong please............. import urllib2 theurl = 'http://www.somerestrictedserver.com'
0
2659
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 "If-None-Match"/"ETag" HTTP headers to conserve bandwidth, but if I'm not mistaken, these are HTTP 1.1 headers, so I can't reasonably expect a web server to respond correctly to my requests. (In my limited testing, it looks like some servers respond correctly with an HTTP 304 status, while some...
2
2642
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 code(see below)
1
4844
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 urllib2.urlopen(req).read()
1
3375
by: Magnus.Moraberg | last post by:
Hi, I have the following code - import urllib2 from BeautifulSoup import BeautifulSoup proxy_support = urllib2.ProxyHandler({"http":"http:// 999.999.999.999:8080"}) opener = urllib2.build_opener(proxy_support)
6
8804
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 for handling errors: there is built in support for URLError (for faulty urls) and HTTPError (for http errors that might originate from, say, passing an invalid stock-ticker in the program below). However I can get neither to work. I'm attaching below the (very short) code: can anyone point out...
2
3921
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 this type: http://www.amazon.com/gp/offer-listing/B000KJX3A0%3FSubscriptionId%3D183VXJS74KNQ89D0NRR2%26tag%3Dws%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3DB000KJX3A0 I can open it in my browser without problems.Any ideas on a solution?
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10495
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10269
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10248
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4148
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2942
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.