473,651 Members | 2,995 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HTTPError sometimes when using urllib2.urlopen

Hi,

I have the following code -

import urllib2
from BeautifulSoup import BeautifulSoup

proxy_support = urllib2.ProxyHa ndler({"http":" http://
999.999.999.999 :8080"})
opener = urllib2.build_o pener(proxy_sup port)
urllib2.install _opener(opener)

page = urllib2.urlopen ('http://www.cornish-language.org/CORNISH/
membership.asp' )
soup = BeautifulSoup(p age)

pageText = soup.findAll(te xt=True)
print pageText

Sometimes when I run this code I get the exception -

HTTPError: HTTP Error 407 Proxy authentication required

I seem to get this error repeatidly for a while, then I go a surf for
a moment and when I run the code again the exception might have gone
away. No idea why...

I have no problems with firefox which uses the same proxy. The proxy
requires no authentication. ..

What might the issue be?

Thanks,

Barry.
Jun 27 '08 #1
1 3359
On 27 Maj, 11:03, Magnus.Morab... @gmail.com wrote:
Hi,

I have the following code -

import urllib2
from BeautifulSoup import BeautifulSoup

proxy_support = urllib2.ProxyHa ndler({"http":" http://
999.999.999.999 :8080"})
opener = urllib2.build_o pener(proxy_sup port)
urllib2.install _opener(opener)

page = urllib2.urlopen ('http://www.cornish-language.org/CORNISH/
membership.asp' )
soup = BeautifulSoup(p age)

pageText = soup.findAll(te xt=True)
print pageText

Sometimes when I run this code I get the exception -

HTTPError: HTTP Error 407 Proxy authentication required

I seem to get this error repeatidly for a while, then I go a surf for
a moment and when I run the code again the exception might have gone
away. No idea why...

I have no problems with firefox which uses the same proxy. The proxy
requires no authentication. ..

What might the issue be?

Thanks,

Barry.
I'm running with Python 2.5 with PythonWin

Heres the full exception -

Traceback (most recent call last):
File "C:\Python25\Li b\site-packages\python win\pywin\frame work
\scriptutils.py ", line 409, in ImportFile
reload(sys.modu les[modName])
File "C:\Documen ts and Settings\konbgn \Desktop\parse. py", line 8, in
<module>
page = urllib2.urlopen ('http://www.cornish-language.org/CORNISH/
membership.asp' )
File "C:\Python25\li b\urllib2.py", line 121, in urlopen
return _opener.open(ur l, data)
File "C:\Python25\li b\urllib2.py", line 380, in open
response = meth(req, response)
File "C:\Python25\li b\urllib2.py", line 491, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python25\li b\urllib2.py", line 418, in error
return self._call_chai n(*args)
File "C:\Python25\li b\urllib2.py", line 353, in _call_chain
result = func(*args)
File "C:\Python25\li b\urllib2.py", line 499, in http_error_defa ult
raise HTTPError(req.g et_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 407: Proxy Authentication Required
Jun 27 '08 #2

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

Similar topics

4
4456
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
6093
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
2936
by: Herman Geldenhuys | last post by:
Hey. Im trying to post some variables to an URL, but I get an error saying that my XML is parsed incorrectly. I know that it is not. At closer inspection I found out that some module in Python must be screwing up my request when I try to send it. Previously the code worked fine, but the problem occured when I included the proxy/authentication code, so that must be what is messing around with my request.
0
2644
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...
0
2529
by: Ritesh Raj Sarraf | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, In urllib.urlretrieve I can use reporthook to implement a progress bar. But in urllib2.urlopen I can't. I have to use urllib2.urlopen because it throws exceptions which are important to be handled where as urlretrieve is dumb.
2
7757
by: Licheng Fang | last post by:
I use a HTTP proxy to connect to Internet. When I run ulropen command I get HTTP Error 407: Proxy authorization required. Could anybody tell me how to resolve this? Thanks!
4
1213
by: jdvolz | last post by:
I have a script that uses urllib2 to repeatedly lookup web pages (in a spider sort of way). It appears to function normally, but if it runs too long I start to get 404 responses. If I try to use the internet through any other programs (Outlook, FireFox, etc.) it will also fail. If I stop the script, the internet returns. Has anyone observed this behavior before? I am relatively new to Python and would appreciate any suggestions. ...
0
2618
by: Jinshi | last post by:
Hello, everyone, I am quite new to python and I don't know how to solve this problem. I hope someone can help me. I just did a test in python shell: Traceback (most recent call last): File "c:\Zope\<string>", line 1, in ? File "C:\Zope\2.10.5\Python\Lib\urllib2.py", line 130, in urlopen
3
1960
by: Alexnb | last post by:
Okay, I tried to follow that, and it is kinda hard. But since you obviously know what you are doing, where did you learn this? Or where can I learn this? Maric Michaud wrote: class=r>.*?</h2>', -- View this message in context: http://www.nabble.com/using-urllib2-tp18150669p18160312.html
0
8807
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...
1
8466
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
7299
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5615
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
4144
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...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1912
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
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.