[Twisted-Python] Post data
Matteo Giacomazzi
matteo.giacomazzi at libero.it
Mon Oct 27 12:36:21 MST 2003
Hi all,
I need to query a remote HTTP server using POST method.
To achieve this, I use the t.w.c.getPage function.
In order to post some data, I pass to that function the keyword
postdata bound to an urllib.urlencode()-d dictionary but it seems
that such data is not sent at all.
What is wrong?
Here is a minimal example: the url is a PHP scripts that simply
dumps the content of the $_POST variable, but it is an empty
array...
Any help would be greatly appreciated!
#=============================================
from twisted.web.client import getPage
from twisted.internet import reactor
import urllib
def printData(data):
print data
reactor.stop()
payload = urllib.urlencode({'test':'the test'})
url = 'http://www.hotelsprovider.com/~matteo'
d = getPage(url, postdata=payload, timeout=5)
d.addCallback(printData)
reactor.run()
#=============================================
Many thanks in advance!
Kind regards
Matteo
More information about the Twisted-Python
mailing list