本文整理匯總了Python中requests.sessions.Session.verify方法的典型用法代碼示例。如果您正苦於以下問題:Python Session.verify方法的具體用法?Python Session.verify怎麽用?Python Session.verify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類requests.sessions.Session
的用法示例。
在下文中一共展示了Session.verify方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: configure_http_session
# 需要導入模塊: from requests.sessions import Session [as 別名]
# 或者: from requests.sessions.Session import verify [as 別名]
def configure_http_session(size=20, max_retries=1, _session=None):
"""
Return a :class:`requests.Session` object configured with
a :class:`requests.adapters.HTTPAdapter` (connection pool)
for http and https connections.
:param size: The connection pool and maximum size.
:type size: int
:param max_retries: The maximum number of retries for each connection.
:type max_retries: int
:param _session: Test-only hook to provide a pre-configured session.
"""
if _session is not None:
return _session
adapter = HTTPAdapter(
pool_connections=size,
pool_maxsize=size,
max_retries=max_retries,
)
session = Session()
session.mount("http://", adapter)
session.mount("https://", adapter)
session.max_redirects = 1
session.verify = certifi.where()
return session