urllib2 problem, data param not working?

G

Gabriel Rossetti

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top