title: Filling a form using a python script
body: <p>I'm trying to write a python script that will fill a form on a website, send it, and after sending I want to search for a keyword on the resulting webpage.</p>
  
  <p>More specifically, the form is: <a href="https://booking.elal.co.il/newBooking/changeOrder.jsp?LANG=EN&amp;RESSYSTEMID=1" rel="nofollow">https://booking.elal.co.il/newBooking/changeOrder.jsp?LANG=EN&amp;RESSYSTEMID=1</a></p>
  
  <p>When I fill the form manually on the web, after I press the "continue" button I get kind of "processing page", and afterwards I get the webpage that I want to search on it the keyword.</p>
  
  <p>I tried to use the script here: <a href="http://stockrt.github.io/p/handling-html-forms-with-python-mechanize-and-BeautifulSoup/" rel="nofollow">http://stockrt.github.io/p/handling-html-forms-with-python-mechanize-and-BeautifulSoup/</a> , but for some reason after submitting the form when I do: <code>print br.response().geturl()</code> I get the url of the "processing page", and not the url of the webpage I want to search on.</p>
  
  <p>My Code:</p>
  
  <pre><code>import mechanize
  import cookielib
  from BeautifulSoup import BeautifulSoup
  import html2text
  
  # Browser
  br = mechanize.Browser()
  
  # Cookie Jar
  cj = cookielib.LWPCookieJar()
  br.set_cookiejar(cj)
  
  # Browser options
  br.set_handle_equiv(True)
  br.set_handle_gzip(True)
  br.set_handle_redirect(True)
  br.set_handle_referer(True)
  br.set_handle_robots(False)
  
  # Follows refresh 0 but not hangs on refresh &gt; 0
  br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
  
  # User-Agent (this is cheating, ok?)
  br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
  
  # The site we will navigate into, handling it's session
  br.open('https://booking.elal.co.il/newBooking/changeOrder.jsp?LANG=EN&amp;RESSYSTEMID=1')
  
  # Select the first (index zero) form
  br.select_form(nr=0)
  
  # User credentials
  br.form['REC_LOC'] = '...'
  br.form['DIRECT_RETRIEVE_LASTNAME'] = '...'
  
  # Login
  br.submit()
  
  #Trying to print the webpage
  html = br.response().read()
  print html2text.html2text(html)
  </code></pre>
  
  <p>Is it possible to do what I want, and how can I do it?</p>