我使用Python2.7.7向网站发送post请求。Im使用requests模块,代码如下:(NAME和PASS被替换)
r = requests.post("http://play.pokemonshowdown.com/action.php", data="act=login&name=NAME&pass=PASS&challengekeyid="+challstrarr[2]+"&challenge="+challstrarr[3])
print(r.text)
print(r.json())
Json返回的是一个空的Json对象,错误是:一个错误
我请求的网站有以下教程:
you'll need to make an HTTP POST request to http://play.pokemonshowdown.com/action.php with the data act=login&name=USERNAME&pass=PASSWORD&challengekeyid=KEYID&challenge=CHALLENGE
Either way, the response will start with ] and be followed by a JSON object which we'll call data."
我不确定POST请求响应是否是错误的(因此是空白行),或者如果它没有错误,JSON解析是关闭
您应该将dictionary对象传递给
post
函数(data参数),只有在get
方法中才应该传递查询字符串:相关问题 更多 >
编程相关推荐