472,791 Members | 1,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

HTTPError sometimes when using urllib2.urlopen

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)
urllib2.install_opener(opener)

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

pageText = soup.findAll(text=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 3301
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.ProxyHandler({"http":"http://
999.999.999.999:8080"})
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)

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

pageText = soup.findAll(text=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\Lib\site-packages\pythonwin\pywin\framework
\scriptutils.py", line 409, in ImportFile
reload(sys.modules[modName])
File "C:\Documents and Settings\konbgn\Desktop\parse.py", line 8, in
<module>
page = urllib2.urlopen('http://www.cornish-language.org/CORNISH/
membership.asp')
File "C:\Python25\lib\urllib2.py", line 121, in urlopen
return _opener.open(url, data)
File "C:\Python25\lib\urllib2.py", line 380, in open
response = meth(req, response)
File "C:\Python25\lib\urllib2.py", line 491, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python25\lib\urllib2.py", line 418, in error
return self._call_chain(*args)
File "C:\Python25\lib\urllib2.py", line 353, in _call_chain
result = func(*args)
File "C:\Python25\lib\urllib2.py", line 499, in http_error_default
raise HTTPError(req.get_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
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...
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 ?? The highlites don't seem to show here...but line...
1
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...
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 "If-None-Match"/"ETag" HTTP headers to conserve...
0
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...
2
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
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...
0
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...
3
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:...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

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.