URLLIB2 EXCEPTION

Andrew Markebo andrew.markebo at telia.com
Mon Nov 18 07:17:46 EST 2002


/ bart <e_viola at libero.it> wrote:
| Andrew Markebo wrote:
>> / bart <e_viola at libero.it> wrote:
>> | 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?
>> Hmm doesn't the exception have this info? I think like member msg of
>> the exception.. Otherwise you have to dig into what urlopen does,
>> and do the calls to
>> functions in urllib2 yourself. Not too hard if you know python a
>> little ;-)
>>        /Andy
>>
| I have check member msg and it return the info error message. Example
| 'not found'.
| Other member I don't think that are useful to resolve my
| problem. Perhaps fp attribute because I don't know it. Do you know its
| uselfulness?

Read some from the fp and see if it is there the page is.. 

Or I think the easiest is to dig into urrlib or urllib2 and fix the
fetching yourself through "URLopener" instead of "FancyURLopener"
(used by urlopen per default), I think you can more easily handle
cases like this there.. Shouldn't be too hard.. if you know a little
python.

Alternative could be to use my homehacked similar lib.. give me a
call.. ehm mail.. ehm article ;-)

      /Andy

-- 
 The eye of the beholder rests on the beauty!




More information about the Python-list mailing list