【发布时间】:2014-11-07 03:28:59
【问题描述】:
我正在对我们的内部服务器进行简单的 HTTP 请求身份验证,获取 cookie 然后访问 Cassandra RESTful 服务器以获取数据。返回 cookie 时 requests.get() 阻塞。
我有一个成功提取数据的 curl 脚本,我宁愿在纯 python 中处理响应 JSON 数据。
我在下面做错了什么的任何线索?我转储了 cookie,它看起来不错,和我的 curl cookie 非常相似。
克雷格
import requests
import rtim
# this makes the auth and gets the cookie returned, save the cookie
myAuth = requests.get(rtim.rcas_auth_url, auth=(rtim.username, rtim.password),verify=False)
print myAuth.status_code
authCookie=myAuth.headers['set-cookie']
IXhost='xInternalHostName.com:9990'
mylink='http:/%s/v1/BONDISSUE?format=JSONARRAY&issue.isin=%s' % (IXhost, 'US3133XK4V44')
# chokes on next line .... doesn't like the Cookie format
r = requests.get(mylink, cookies=authCookie)
(Pdb) next
TypeError: 'string indices must be integers, not str'
【问题讨论】:
标签: python python-2.7 cookies http-request