title: python - urrlib2 request https site - getting 400 error
body: <p>using the following snip of code to access a url with a post.</p>
  
  <p>i can get it using wget and the following:
   wget --post-data 'p_calling_proc=bwckschd.p_disp_dyn_sched&amp;p_term=201010' <a href="https://spectrumssb2.memphis.edu/pls/PROD/bwckgens.p_proc_term_date" rel="nofollow noreferrer">https://spectrumssb2.memphis.edu/pls/PROD/bwckgens.p_proc_term_date</a></p>
  
  <p>for some reason, i'm having an issue with my python text, in that i get a errorcode of 400. (and of course the browser works as expected)</p>
  
  <p>any thoughts/comments/etc...</p>
  
  <p>the python test that i have:</p>
  
  <p>//==========================================</p>
  
  <pre><code>import urllib 
  import urllib2
  import sys, string
  import time
  import mechanize
  
  Request = urllib2.Request
  urlopen = urllib2.urlopen
  
  headers ={'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}
  query = "p_calling_proc%3Dbwckschd.p_disp_dyn_sched%26p_term%3D201010"
  url1="https://spectrumssb2.memphis.edu/pls/PROD/bwckgens.p_proc_term_date"
  
  req = Request(url1, query, headers)
  
  test1=0
  test=0
  while test==0:
    print "aaaaattttt \n"
    try: 
      res = urlopen(req)
      #req = Request(url1, query, headers)
      print "aaaappppp \n"
      #urllib2.URLError, (e)
      #print e
    except urllib2.HTTPError, e:
      print "ffff1111 "+str(e.code)+"\n"
      if e.code:
        test1=1
        print "error ..sleep \n"
        time.sleep(1)
      else:
        test1=0
    except urllib2.URLError, e:
      print e.reason
      #print "ffff3333 "+e.code+"\n"
      if e.reason:
        test1=1
        print "error ..sleep \n"
        time.sleep(1)
      else:
        test1=0
    #print "ddd "+e.code +"\n"
    #print e
    if test1==0:
      test=1
  
  print "test1 = "+str(test1)+"\n"
  #res = urlopen(req)
  print "gggg 000000000000\n"
  s = res.read()
  </code></pre>
  
  <p>.</p>
  
  <hr>
  
  <p>any thoughts/comments would be appreciated..</p>
  
  <p>thanks</p>