[英]How to request data to JSON-RPC using python
I want to dump some data from a website with JSON-RPC but i cant get any information. 我想从使用JSON-RPC的网站转储一些数据,但我无法获得任何信息。 I'm using post request and even simulating headers using python but seems like isn't enough...
我正在使用post请求甚至使用python模拟头文件但似乎还不够......
Im getting this error: {"error":{"code":590,"msg":"couldn't parse request arguments"}} 我收到此错误:{“error”:{“code”:590,“msg”:“无法解析请求参数”}}
code: 码:
#!/usr/bin/python
import urllib,urllib2,json,httplib
url = 'localhost'
parameters = {'method':'buscador.obtenerGruposAsignaturas',"params":json.dumps(["2025333","0"])}
data = urllib.urlencode(parameters)
headers = {
"Content-Type": "application/json",
'Content-Length' : len(data),
"Referer":"localhost",
"Cookie":'JSESSIONID=2C6BBA00328C1C2F67794E50337D6E3A.N1TS002'
"User-Agent":'Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20100101 Firefox/10.0.1'}
conn=httplib.HTTPConnection(url,80)
conn.request("POST","/search/JSON-RPC",data,headers)
page = conn.getresponse().read()
print page
Thanks for comments or suggestions 感谢您的意见或建议
如果你使用的是JSON-RPC,也许你应该在json而不是urlencode中编码parameters
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.