代码:
#coding:utf-8
import requests
import json
url = "http://m.imooc.com/passport/user/login"
data = {
"username": "18513199586",
"password": "111111",
"verify": "",
"referer": "https://m.imooc.com"
}
res=requests.post(url,data).json()
response_url= res['data']['url'][0]
response_url=response_url+"&callback=jQuery21008240514814031887_1508666806"
cookie=requests.get(response_url).cookies
#cookie=requests.utils.dict_from_cookiejar(cookie) #cookiejar转换为字典
#print cookie
#print cookie['apsid']
url1="http://order.imooc.com/pay/submitorder?jsonpcallback=jQuery111301426289146376727_1535897916059&goods_ids=1082&_=1535897916066"
print requests.get(url1).text
#print requests.get(url1).text
运行结果:
Traceback (most recent call last):
File "J:/imoocInterface/util/operation_header_cainiao.py", line 12, in <module>
response_url= res['data']['url'][0]
TypeError: list indices must be integers, not str
代码如截图: