client.getPage('url', method='POST',
postdata=urllib.urlencode({'doc': {somedata}}))
这对我不起作用,我得到了“空数据”作为回应。似乎postdata只是一个笑话
答案 0 :(得分:3)
当我添加application/x-www-form-urlencoded
时,它适用于Python2:
import urllib
from twisted.internet import reactor
from twisted.web import client
client.getPage('http://requestb.in/vvs5qdvv', method='POST',
headers={'Content-Type': 'application/x-www-form-urlencoded'},
postdata=urllib.urlencode({'doc':'data'}));
reactor.run()
请在此处查看已发送的数据:http://requestb.in/vvs5qdvv?inspect