title: Python: clicking a button
body: <p>I have problems in clicking this button that looks in HTML code like this:</p>
  
  <pre><code>&lt;form method="post"&gt;
  &lt;br&gt;
  &lt;input type="hidden" value="6" name="deletetree"&gt;
  &lt;input type="submit" value="Delete Tree" name="pushed"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and the url that needs to be generated looks like this:
  <a href="http://mysite.com/management.php?Category=2&amp;id_user=19&amp;deteletree=6&amp;pushed=Delete+Tree" rel="nofollow">http://mysite.com/management.php?Category=2&amp;id_user=19&amp;deteletree=6&amp;pushed=Delete+Tree</a></p>
  
  <p>Update:
  I tried this, but it doesnt work:</p>
  
  <pre><code>form_data = urllib.urlencode({'Category' : '2', 'suid' : '19', 'deletetree' : '6', 'pushed' : 'Delete+Tree' })
  urllib2.urlopen("management.php", form_data)
  </code></pre>
  
  <p>This is how I log in:</p>
  
  <pre><code>cj = cookielib.CookieJar() 
  opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) 
  opener.addheaders = [('User-agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.29 Safari/525.13')] 
  username = "user" 
  password = "pass" 
  USER_ID = '6'
  
      loginonsite = login("http://mysite.com/myprofile.php",
                          "login_username=%s&amp;login_password=%s&amp;suid=%s".format(username, password, USER_ID)
  </code></pre>
  
  <p>)</p>