我第一次尝试使用pycurl
而且我不确定如何使用参数。
curl "https://mytest.com/mdb.json"
-H "Cookie: JSESSIONID=6CCB148AEE7318BD08EFC869E0FD33AB; user=testuser; wmUserPrincipal="%"7B"%"22username"%"22"%"3A"%"22testuser"%"22"%"2C"%"22roles"%"22"%"3A"%"5B"%"5D"%"7D; mf_user=322383eec941db6c72f3f2c7d58b7a80"
-H "Content-Type: application/json-rpc"
-H "Accept: */*"
-H "X-Requested-With: XMLHttpRequest"
-H "Connection: keep-alive" --data-binary "{""params"":[""1.2.1"",""instance7"",""1.2"",4,{}],""method"":""getMatrix"",""id"":250}" --compressed
正如卷曲中所见:
--data-binary "{""params"":[""1.2.1"",""instance7"",""1.2"",4,{}],""method"":""getMatrix"",""id"":250}" --compressed
我在pycurl
中无法弄清楚如何处理它们。也许它甚至不可能,或者可能有一个比使用pycurl
更简单的解决方案。
谢谢!
答案 0 :(得分:0)
让它与requests
一起运行,这比我需要的更简单。
cookie = {
'JSESSIONID': '6CCB148AEE7318BD08EFC869E0FD33AB',
'user': 'testuser',
'wmUserPrincipal': '%7B%22username%22%3A%22testuser%22%2C%22roles%22%3A%5B%5D%7D',
'mf_user': '322383eec941db6c72f3f2c7d58b7a80',
}
head = {
'Content-Type': 'application/json-rpc',
'Accept': '*/*',
'X-Requested-With': 'XMLHttpRequest',
'Connection': 'keep-alive',
}
data = '{"params":["1.2.1","instance7","1.2",4,{}],"method":"getMatrix","id":250}'
requests.post('https://mytest.com/mdb.json', headers=head, cookies=cookie, data=data)