urllib2 problem, data param not working?

Discussion in 'Python' started by Gabriel Rossetti, Mar 31, 2009.

  1. 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
    Gabriel Rossetti, Mar 31, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Geathaa
    Replies:
    2
    Views:
    676
    Geathaa
    Jul 30, 2003
  2. Tjerk Wolterink

    XSL:param data-types

    Tjerk Wolterink, Nov 20, 2004, in forum: XML
    Replies:
    1
    Views:
    778
    Tjerk Wolterink
    Nov 20, 2004
  3. Josef Cihal
    Replies:
    0
    Views:
    717
    Josef Cihal
    Sep 5, 2005
  4. ectoplasm
    Replies:
    12
    Views:
    619
    Zorro
    Jul 28, 2005
  5. Dave
    Replies:
    5
    Views:
    611
    John Bokma
    Apr 26, 2011
Loading...

Share This Page