title: How to request post to aspx site in python?
body: <p>This is the url I'm trying to parse.
  url = 'https://www.ncsl.org/research/energy/energy-legislation-tracking-database.aspx'
  I'm trying to select &quot;all state&quot; and &quot;all topic&quot; option, and retrieve the search output.</p>
  <pre><code>def Generate_params(tn=22, sn=55, searchyear=2008, vr=vrstring):
      topicstring = &quot;dnn$ctr85406$StateNetDB$ckBxTopics$&quot;
      statestring = 'dnn$ctr85406$StateNetDB$ckBxStates$'
      params = {}
      params['dnn$ctr85406$StateNetDB$ckBxAllTopics']='on'
      params['dnn$ctr85406$StateNetDB$ckBxAllStates']='on'
      for t in range(tn+1):
          topic_n = topicstring+&quot;{}&quot;.format(t)
          params[topic_n]='on'
      for s in range(sn+1):
          state_n = statestring+&quot;{}&quot;.format(s)
          params[state_n]='on'
      # vrstring is a string parameter I have outside the function. 
      params['__VIEWSTATE']=vrstring
      params['dnn$ctr85406$StateNetDB$ddlYear']=str(searchyear)
      params['dnn$ctr85406$StateNetDB$btnSearch']='Search'
      params['__VIEWSTATEGENERATOR']='CA0B0334'
      return params
  
  from requests import Request, Session
  post_params=Generate_params()
  session = Session()
  response = session.post(url, headers=headers,data=post_params)
  </code></pre>
  <p>But the returned response don't have the search output. What did I do wrong?</p>