使用urllib2时我的请求正常,但在使用请求时出现403错误。
data[1:5, ]
200
import urllib2
url = 'https://api.optconnect.com/summit/beta/accounts/login/app_secret'
data = {'accountId': 000,
'applicationId': 000,
'secret': '000'}
data = json.dumps(data)
headers = {'accept': 'application/json', 'content-type': 'application/json' }
req = urllib2.Request(url, data ,headers)
response = urllib2.urlopen(req)
print(response.getcode())
403
答案 0 :(得分:0)
而不是
req = requests.get(url=url, data=data, headers=headers)
试
req = requests.post(url=url, data=data)