Simple Python POST urlencode()
Question: I'm trying to send a POST to my Node.js app using Python. Here is my code

    
    
    import urllib
    import urllib2
    
    url = my_url
    values = {'email' : my_email,
          'password' : my_password }
    data = urllib.urlencode(values)
    
    req = urllib2.Request(url,data)
    response = urllib2.urlopen(req)
    the_page = response.read()
    
    print(the_page)
    

The request is sent, but somehow the parameters are getting messed up because
the response I am getting corresponds to invalid login credentials.

I can do this same request using Postman for Chrome and it works just fine. So
I know it's not something with my API.

So essentially I can do GET requests just fine with Python but for some
reason, when I try to include parameters in a POST they are not translated
correctly.

I've already looked through the docs for urllib, urllib2 and urlencode(). I
could not find anything helpful


Answer: I do no longer debug urllib2 problems, since I switched to requests, I do no
longer have them, you may do so:

    
    
    import requests
    
    print requests.post(my_url, data={'email': my_email, 'password': my_password}).text
    

So readable, so elegant... If your jquery app returns json, you may use
".json()" instead of ".text"

Your problem seems to have to keep cookies, to do so, you may just use a
[requests session](http://docs.python-requests.org/en/latest/user/advanced/)

