title: Python Web Login Script not working
body: <p>I'm trying to implement a basic Python login script with cookies. I've looked at umpteen examples here and elsewhere and I cannot get past this "urllib2.HTTPError: HTTP Error 405: Method Not Allowed" error.</p>
  
  <p>The script has been copied and crosschecked with a dozen others and I think it makes sense - so perhaps the issue is with the HTML or the webserver? JavaScript is the extent of my web scripting so apologies in advance if the error is embarrassingly obvious.</p>
  
  <p>HTML (index.html):</p>
  
  <pre><code>&lt;form id="loginForm" action="login.py" method="post"&gt;
  &lt;div class="loginDiv"&gt;
      &lt;div class="inputDiv"&gt;
          &lt;label for="user" id="user-label"&gt;User:&lt;/label&gt;
          &lt;input id="username" type="text" name="handle" value=""
                 autocomplete="off" class="roundedInputs" style="color:White;width:160px;" /&gt;             
      &lt;/div&gt;
      &lt;div class="inputDiv"&gt;
          &lt;label for="pass" id="pass-label"&gt;Pass:&lt;/label&gt;
          &lt;input id="password" type=password name="password" value=""
                 autocomplete="off" class="roundedInputs"
                 style="color:White;width:160px;" /&gt;              
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="submitDiv"&gt;
      &lt;input id="sumbitLogin" class="sumbitStyle" type="submit" value="&amp;#187;&amp;nbsp;ENTER&amp;nbsp;&amp;#171;" /&gt;
  &lt;/div&gt;      
  &lt;/form&gt;
  </code></pre>
  
  <p>and Python (login.py)</p>
  
  <pre><code>import cookielib
  import urllib
  import urllib2
  
  username = 'myuser'
  password = 'mypassword'
  
  
  values = {'username' : username,
            'password' : password }
  
  cj = cookielib.CookieJar()
  opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
  login_data = urllib.urlencode(values)
  opener.open('http://&lt;address&gt;:8080/index.html', login_data)
  resp = opener.open('http://&lt;address&gt;:8080/FTP/')
  http_headers = response.info()
  print resp.read()
  </code></pre>
  
  <p>I'm on the verge of giving up entirely and writing it in something else so any help would be really appreciated.</p>