urllib2 problem, data param not working?

Gabriel Rossetti gabriel.rossetti at arimaz.com
Tue Mar 31 18:44:30 CEST 2009


Hello everyone,

I am having a problem with urllib2, when I do this :

    post = urllib.urlencode(post)
    request = urllib2.Request(url, post)
    response = urllib2.urlopen(request)

or this :

    post = urllib.urlencode(post)
    response = urllib2.urlopen(url, post)

or this :

    post = urllib.urlencode(post)
    request = urllib2.Request(url)
    response = urllib2.urlopen(request, post)

it doesn't work, it's like if the post params weren't added, and if I do 
this :

    post = urllib.urlencode(post)
    request = url + '?' + post
    response = urllib2.urlopen(request)

it works as expected, can anyone explain what is going on? I know that 
if I don't add the data ('post' in my case) param it uses an HTTP GET, 
could that be why it works when I add them manually?

Thank you,
Gabriel



More information about the Python-list mailing list