title: Python 3.2.3 to log into secure website
body: <p>Using python 3.2.3 I am trying to log into some websites and save the source from a hidden page to a file. I am stuck on how to log in. I have figured out how to log into a specific website but can't seem to get it working on others. The source of the webpage I am trying to log into is:</p>
  
  <pre><code>&lt;form id="login_form" name="login_form" action="https://www.o2online.ie/amserver/UI/Login?org=o2ext&amp;goto=%2F%2Fwww.o2online.ie%2Fo2%2Fmy-o2%2F" method="post"&gt;
                                      &lt;p id="form_header"&gt;My Account login&lt;/p&gt;
                                      &lt;input value="Go" type="hidden" name="IDButton" id="IDButton"/&gt;
                                      &lt;input value="o2ext" type="hidden" name="org" id="org"/&gt;
                                      &lt;input value="TRUE" type="hidden" name="CONNECTFORMGET"/&gt;
                                      &lt;label for="IDToken1"&gt;Username&lt;/label&gt;&lt;br /&gt;
                                      &lt;input tabindex=1 type="text" id="IDToken1" name="IDToken1" value="Username/mobile" onclick="javascript: this.value='';" maxlength="60"  onfocus="this.value='';" tabindex=1 /&gt;&lt;br /&gt;
                                      &lt;br /&gt;
                                      &lt;label for="IDToken2"&gt;Password&lt;/label&gt;&lt;br /&gt;
                                      &lt;input tabindex=2 type="password" id="IDToken2" name="IDToken2" value="" maxlength="30"  onfocus="this.value='';" tabindex=2 /&gt;
                                      &lt;input tabindex=3 type="image" src="../images/my-o2/Login-button.png" id="submit_button" /&gt;
                                  &lt;/form&gt;
  </code></pre>
  
  <p>On the other pages that I have logged into sucessfully have had a submit button with a certain value but this webpage has an image for the submit button which has no value.</p>
  
  <p>The code I have been using is:</p>
  
  <pre><code>import urllib.request
  import urllib.parse
  import http.client
  import sys
  
  url = 'http://www.o2online.ie/o2/login/'
  login_data = {
               'IDToken1': 'xxxx',
               'IDToken2': 'xxxx',
               #'submitbutton': 'submit'                           
               }
  
  # creating an opener object that will handle the cookies
  opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor)
  
  r = opener.open(url, urllib.parse.urlencode(login_data).encode())
  
  # logged in
  
  #Opening and saving source to a file
  f = opener.open('http://www.o2online.ie/o2/my-o2/')
  sys.stdout = open('file.html', 'w')
  print (f.read(999999))
  </code></pre>
  
  <p>I have commented out the submit button.</p>
  
  <p>Can this code be modified to log into this website?</p>
  
  <p>How would you submit this form in python?</p>