title: Submit form with urllib Python 3.4
body: <p>I want to login to a site with urllib in Python 3.4</p>
  
  <pre><code>import urllib.parse
  import urllib.request
  import http.cookiejar
  
  cj = http.cookiejar.CookieJar()
  opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
  opener.addheaders = [('User-agent', 'Mozilla/5.0')]
  urllib.request.install_opener(opener)
  url = 'http://mysite.org'
  values = {"username" : "MyUsername123", 
            "password" : "MyPass123"}
  data = urllib.parse.urlencode(values)
  binary_data = data.encode('utf8')
  req = urllib.request.Request(url, binary_data)
  response = urllib.request.urlopen(req).read().decode("utf8", 'ignore')
  print(response)
  </code></pre>
  
  <p>When i run this, the output is the login page, not the page after you log in.
  In Python 2.7 i did it with mechanize, and now i can't because it's not compatible with 3.4.</p>