本文整理汇总了Python中requests.Request.auth方法的典型用法代码示例。如果您正苦于以下问题:Python Request.auth方法的具体用法?Python Request.auth怎么用?Python Request.auth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类requests.Request
的用法示例。
在下文中一共展示了Request.auth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sendHttpRequest
# 需要导入模块: from requests import Request [as 别名]
# 或者: from requests.Request import auth [as 别名]
def sendHttpRequest(_args):
s = Session()
url = makeURL(_args)
req = Request(_args.get("method"), url)
if (_args.get("headers") is not None) : req.headers = _args.get("headers")
if (_args.get("auth") is not None) : req.auth = HTTPBasicAuth(_args.get("auth")[0], _args.get("auth")[1])
if (_args.get("params") is not None) : req.params = _args.get("params")
if (_args.get("cookies") is not None) : req.cookies = _args.get("cookies")
if (_args.get("data") is not None) : req.data = _args.get("data")
prepped = req.prepare()
if (_args.get("body") is not None) : prepped.body = _args.get("body")
# do something with prepped.body
# do something with prepped.headers
resp = s.send(prepped,timeout=_args.get("timeout"), proxies=_args.get("proxies"))
return resp