title: Python crawler can not successfully sent out form
body: <p>I am new to Python and trying to crawling the some information on my school website (based on aspx). </p>
  
  <p>What I am trying to do is:</p>
  
  <ol>
  <li><p><a href="http://url.of.the.page" rel="nofollow noreferrer">http://url.of.the.page</a></p></li>
  <li><p>Login</p></li>
  <li><p>Open the 4th link on the left</p></li>
  </ol>
  
  <p>I was trying to log into my account by using <code>req = urllib2.Request(url,data)</code> (the <code>data</code> contains the id, password and some other information I can see through wireshark) together with <code>result = opener.open(req)</code> and <code>print result.read()</code>.</p>
  
  <p>Unfortunately the result printed out is the same as the original login page, so I guess I did not login successfully, this result is also same as when I click the 4th lick without login.
  (Another proof is that when I wanted to get another link on the web page, I was redirected to the login page).</p>
  
  <p>My question will be:</p>
  
  <ol>
  <li>Do I really fail to login?</li>
  <li>If so what is the correct way to login?</li>
  </ol>
  
  <p>My code is as follow:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  import urllib2
  import urllib
  import cookielib
  from bs4 import BeautifulSoup
  import datetime
  import time
  from urlgrabber.keepalive import HTTPHandler
  
  def get_ViewState(soup):      
      view_input = soup.find(id="__VIEWSTATE")      
      return (view_input['value'])  
  
  def get_EventValidation(soup):  
      event_input = soup.find(id="__EVENTVALIDATION")  
      return event_input['value'] 
  
  cookie = cookielib.CookieJar()
  keepalive_handler = HTTPHandler()
  opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie),keepalive_handler)
  urllib2.install_opener(opener)
  
  __url = 'http://url.of.the.page'
  
  opener.addheaders = [('User-agent','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36')
                      ,('Connection', 'Keep-Alive')
                      ,('Referer',__url)] 
  
  
  page = urllib.urlopen(__url).read()
  soup = BeautifulSoup(page)
  
  viewstate = get_ViewState(soup)  
  eventvalidation = get_EventValidation(soup)
  
  postdata = urllib.urlencode({
          '__EVENTTARGET':'',
          '__EVENTARGUMENT:':'', 
          '__VIEWSTATE':viewstate, 
          'TxtStudentId':'xxxxxxx',    
          'TxtPassword':'xxxxxxx',
          'BtnLogin':'login',
          '__EVENTVALIDATION':eventvalidation
          })
  
  
  
  
  req = urllib2.Request(
          url = __url,    
          data = postdata  
      )
  
  result = opener.open(req)
  print result.read()
  # result = opener.open(req)
  # print result.info()
  
  # print result    
  # print result.read() 
  
  print "------------------------------------------------"
  
  #after login, I need to get the scores table
  __queryUrl = 'http://url.of.the.page?key=0'
  now = datetime.datetime.now()
  opener.addheaders = [('Referer', 'http://url.of.the.page?i='+now.strftime('%H:%M:%S'))]
  
  result = opener.open(__queryUrl)
  print result.read()
  
  for item in cookie:    
          print 'Cookie：Name = '+item.name    
          print 'Cookie：Value = '+item.value 
  </code></pre>