我想在Python中复制以下curl命令。
curl -u : --negotiate -k https://example.com/authenticate
我在这里跟踪了这个pycurl示例,它工作正常 http://www.deplication.net/2014/02/curl-with-kerberos-authentication.html
curl = pycurl.Curl()
curl.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_GSSNEGOTIATE)
curl.setopt(pycurl.USERPWD, ':')
curl.setopt(pycurl.URL, 'https://example.com/authenticate'
curl.perform()
有没有办法用Python请求模块做到这一点?
谢谢!
答案 0 :(得分:0)
您可以尝试以下项目:https://pypi.org/project/requests-negotiate/,或者如果您使用的是Kerberos:https://pypi.org/project/requests-kerberos/
使用任一方法,您的代码将如下所示:
auth = HTTPNegotiateAuth() # or: HTTPKerberosAuth()
response = requests.get('https://example.com/authenticate', auth=auth, verify=False)