异常:
以下是request.exceptions模块下的异常错误:
- RequestException:所有异常的基类。
- HTTPError(RequestException):HTTP错误。
- UnrewindableBodyError(RequestException):请求在尝试回放正文时遇到错误。
- RetryError(RequestException):自定义重试逻辑失败(Custom retries logic failed)。
- ConnectionError(RequestException):发生连接错误。
- ProxyError(ConnectionError):发生代理错误。
- SSLError(ConnectionError):出现SSL错误。
- ConnectTimeout(ConnectionError, Timeout):链接超时。
- Timeout(RequestException):请求超时;监听此异常将同时监听
ConnectTimeout
和ReadTimeout
异常。 - ReadTimeout(Timeout):响应超时,服务器在规定的时间内未发送任何数据。
- URLRequired(RequestException):无效的URL。
- TooManyRedirects(RequestException):重定向次数太多。
- MissingSchema(RequestException, ValueError):URL缺少资源类型(例如http、https或ftp)。
- InvalidSchema(RequestException,ValueError):URL指定的资源类型无效,或不支持的资源类型(See defaults.py for valid schemas.)。
- InvalidURL(RequestException,ValueError):无效URL。
- InvalidHeader(RequestException,ValueError):无效的请求头。
- ChunkedEncodingError(RequestException):服务器声明了分块编码,但发送了无效的分块。(The server declared chunked encoding but sent an invalid chunk.)。
- StreamConsumedError(RequestException,TypeError):此响应的内容已被使用。
- ContentDecodingError(RequestException,BaseHTTPError):未能解码响应内容。
- InvalidJSONError:JSON错误。
- InvalidProxyURL(InvalidURL):提供的代理URL无效。
警告:
以下是request.exceptions模块下的异常警告:
- RequestsWarning(Warning):请求的基本警告。
- FileModeWarning(RequestsWarning, DeprecationWarning):文件以文本模式打开,但请求决定了其二进制长度。
- RequestsDependencyWarning(RequestsWarning):导入的依赖项与预期的版本范围不匹配。