title: python requests POST cookie session
body: <p>Folks,
    Trying to learn <code>requests</code> module for python... and a simple project to pull any pending parking tickets.</p>
  
  <p>Is this the correct way to save session and cookies between a <code>GET</code> and a <code>POST</code> request?</p>
  
  <pre><code>#!/usr/bin/env python
  
  import requests
  import urllib
  
  session = requests.Session()
  
  tokenRequest = session.get('https://paydirect.link2gov.com/NYCParking-Plate/ItemSearch')
  sessionToken = tokenRequest.cookies['__RequestVerificationToken']
  sessionCookies = tokenRequest.cookies
  sessionHeaders = tokenRequest.headers
  
  payload = {
      '__RequestVerificationToken': sessionToken,
      'ItemSearchQuestionUserInput': 'myplate',
      'Questions[0].IsRequired': 'True',
      'Questions[0].Sequence': 1,
      'Questions[0].Text': 'PlateNumber',
      'Questions[0].Type': 'Text',
      'ItemSearchQuestionUserInput[1].QuestionAnswer': 'NY',
      'Questions[1].IsRequired': 'True',
      'Questions[1].Sequence': 2,
      'Questions[1].Text': 'State',
      'Questions[1].Type': 'Text',
      'Questions[2].IsRequired': 'False',
      'Questions[2].Sequence': 3,
      'Questions[2].Text': 'PlateType',
      'Questions[2].Type': 'Text',
      'SubmitButton': 'Continue'
  }
  raw = urllib.urlencode(payload)
  plateRequest = session.post('https://paydirect.link2gov.com/NYCParking-Plate/ItemSearch/Submit', data=raw, headers=sessionHeaders, cookies=sessionCookies)
  
  print plateRequest.text
  </code></pre>
  
  <p>Does not seem to work...  Im sure its something simple i am missing.  Their website is here: <a href="https://paydirect.link2gov.com/NYCParking-Plate/ItemSearch" rel="nofollow">https://paydirect.link2gov.com/NYCParking-Plate/ItemSearch</a></p>
  
  <p>Thanks!</p>