有什么方法可以使 post 一些数据扭曲?
Is there any way to async post some data with twisted?
client.getPage('url', method='POST',
postdata=urllib.urlencode({'doc': {somedata}}))
这对我不起作用,我得到了 "empty data" 的回应。似乎 postdata 只是一个笑话
当我添加 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
client.getPage('url', method='POST',
postdata=urllib.urlencode({'doc': {somedata}}))
这对我不起作用,我得到了 "empty data" 的回应。似乎 postdata 只是一个笑话
当我添加 application/x-www-form-urlencoded
:
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