Movatterモバイル変換


[0]ホーム

URL:


Navigation

21.9.urllib.error — Exception classes raised by urllib.request

Theurllib.error module defines the exception classes for exceptionsraised byurllib.request. The base exception class isURLError.

The following exceptions are raised byurllib.error as appropriate:

exceptionurllib.error.URLError

The handlers raise this exception (or derived exceptions) when they run intoa problem. It is a subclass ofOSError.

reason

The reason for this error. It can be a message string or anotherexception instance.

Changed in version 3.3:URLError has been made a subclass ofOSError insteadofIOError.

exceptionurllib.error.HTTPError

Though being an exception (a subclass ofURLError), anHTTPError can also function as a non-exceptional file-like returnvalue (the same thing thaturlopen() returns). Thisis useful when handling exotic HTTP errors, such as requests forauthentication.

code

An HTTP status code as defined inRFC 2616. This numeric value correspondsto a value found in the dictionary of codes as found inhttp.server.BaseHTTPRequestHandler.responses.

reason

This is usually a string explaining the reason for this error.

exceptionurllib.error.ContentTooShortError(msg,content)

This exception is raised when theurlretrieve()function detects thatthe amount of the downloaded data is less than the expected amount (given bytheContent-Length header). Thecontent attribute stores thedownloaded (and supposedly truncated) data.

Previous topic

21.8.urllib.parse — Parse URLs into components

Next topic

21.10.urllib.robotparser — Parser for robots.txt

This Page

Quick search

Enter search terms or a module, class or function name.

Navigation

©Copyright 1990-2017, Python Software Foundation.
The Python Software Foundation is a non-profit corporation.Please donate.
Last updated on Sep 19, 2017.Found a bug?
Created usingSphinx 1.2.

[8]ページ先頭

©2009-2025 Movatter.jp