已弃用的请求实用程序¶
Requests 已 决定在 requests.utils
中弃用一些实用程序函数。为了方便用户,这些函数已移至 requests_toolbelt.utils.deprecated
。
requests.utils 中已弃用的函数集合。
- requests_toolbelt.utils.deprecated.find_charset(string, pos=0, endpos=9223372036854775807)¶
返回 string 中与 pattern 完全匹配的所有非重叠匹配项的列表。
- requests_toolbelt.utils.deprecated.find_pragma(string, pos=0, endpos=9223372036854775807)¶
返回 string 中与 pattern 完全匹配的所有非重叠匹配项的列表。
- requests_toolbelt.utils.deprecated.find_xml(string, pos=0, endpos=9223372036854775807)¶
返回 string 中与 pattern 完全匹配的所有非重叠匹配项的列表。
- requests_toolbelt.utils.deprecated.get_encodings_from_content(content)¶
从给定的内容字符串中返回编码。
import requests from requests_toolbelt.utils import deprecated r = requests.get(url) encodings = deprecated.get_encodings_from_content(r)
- requests_toolbelt.utils.deprecated.get_unicode_from_response(response)¶
以 Unicode 形式返回请求的内容。
这将首先尝试从响应头中检索编码。如果失败,它将使用
requests_toolbelt.utils.deprecated.get_encodings_from_content()
从 HTML 元素中确定编码。import requests from requests_toolbelt.utils import deprecated r = requests.get(url) text = deprecated.get_unicode_from_response(r)
- 参数:
response (requests.models.Response) – 要从中获取 Unicode 内容的响应对象。