[Twisted-Python] Post data

Matteo Giacomazzi matteo.giacomazzi at libero.it
Mon Oct 27 14:36:21 EST 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

  Any help would be greatly appreciated!

from twisted.web.client import getPage
from twisted.internet import reactor
import urllib

def printData(data):
    print data

payload = urllib.urlencode({'test':'the test'})
url = 'http://www.hotelsprovider.com/~matteo'
d = getPage(url, postdata=payload, timeout=5)
  Many thanks in advance!

Kind regards

More information about the Twisted-Python mailing list