Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

URLLIB2 EXCEPTION

3 views
Skip to first unread message

bart

unread,
Nov 16, 2002, 12:29:11 PM11/16/02
to
I use function urllopen to connect to http web page. When resource
doesn't present in location, urllopen returns exception. The web server,
in this occasion, generates a page to communicate the error, but urlopen
doesn't return it.

What can I do to receive error page source code by urlopen?

Thanks ...

Ennio Viola

italian languagge translate:

Utilizzo la funzione urlopen per connettermi a pagine web. Quando la
risorsa non esiste, urlopen ritorna un'eccezione e non il codice
sorgente della pagina generata dal web server in questi casi.

Come posso fare per recuperare tale pagina?

Grazie...

bart

unread,
Nov 19, 2002, 2:45:42 PM11/19/02
to
Sometime, when I use urlopen function, happen this:

Traceback (most recent call last):
File "<stdin>", line 2, in ?
File "/usr/local/lib/python2.2/urllib2.py", line 138, in urlopen
return _opener.open(url, data)
File "/usr/local/lib/python2.2/urllib2.py", line 322, in open
'_open', req)
File "/usr/local/lib/python2.2/urllib2.py", line 301, in _call_chain
result = func(*args)
File "/usr/local/lib/python2.2/urllib2.py", line 790, in http_open
return self.do_open(httplib.HTTP, req)
File "/usr/local/lib/python2.2/urllib2.py", line 784, in do_open
return self.parent.error('http', req, fp, code, msg, hdrs)
File "/usr/local/lib/python2.2/urllib2.py", line 342, in error
result = self._call_chain(*args)
File "/usr/local/lib/python2.2/urllib2.py", line 301, in _call_chain
result = func(*args)
File "/usr/local/lib/python2.2/urllib2.py", line 434, in http_error_302
return self.parent.open(new)
File "/usr/local/lib/python2.2/urllib2.py", line 322, in open
'_open', req)
File "/usr/local/lib/python2.2/urllib2.py", line 301, in _call_chain
result = func(*args)
File "/usr/local/lib/python2.2/urllib2.py", line 790, in http_open
return self.do_open(httplib.HTTP, req)
File "/usr/local/lib/python2.2/urllib2.py", line 779, in do_open
code, msg, hdrs = h.getreply()
File "/usr/local/lib/python2.2/httplib.py", line 1009, in getreply
response = self._conn.getresponse()
File "/usr/local/lib/python2.2/httplib.py", line 760, in getresponse
response.begin()
File "/usr/local/lib/python2.2/httplib.py", line 269, in begin
version, status, reason = self._read_status()
File "/usr/local/lib/python2.2/httplib.py", line 231, in _read_status
line = self.fp.readline()
IOError: [Errno 104] Connection reset by peer


I understood that connection can be reseted but I managed this exception
cases: HTTPError and URLError. I don't know another exception that can
be generate in urllib2. Besides IOError exception doesn't present inside
urllib2. What can I do to resolve my problem? Where I can found (web
site, manual and other) a solution?

Thanks to help me...

- Ennio -

0 new messages