title: How to login into a website (wifi login page) using python?
body: <p>I want to login into a wifi login page using python , using a set of usernames and passwords, in case data limit of a accounts ends automatically. Can any one help me?</p>
  
  <p>The script should automatically check if data limit is over and then login using the next set of username and password.</p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;&lt;html&gt;
  &lt;head&gt;              
  &lt;title&gt;Captive Portal&lt;/title&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
  &lt;meta http-equiv="pragma" content="no-cache" /&gt;
  &lt;meta http-equiv="expires" content="-1"/&gt;
  &lt;script language="JavaScript" src="/javascript/cyberoamAjax.js"&gt;&lt;/script&gt;
  &lt;script language="JavaScript"&gt;
  var message = "";
  var status = "LOGIN";
  var ack = "";
  var userName = "";
  userName = userName.replace(new RegExp("''", 'g'),"'")
  var password = "";
  var timer="";
  var liveReqTimeInJS=180;
  &lt;/script&gt;
  &lt;script language="JavaScript" src="/javascript/validation/httpclient.js?ver=60223"&gt;&lt;/script&gt;&lt;link rel="stylesheet" href="/css/cyberoam.css?ver=47600" /&gt;&lt;/head&gt;&lt;script language='JavaScript'&gt;document.title='KIIT Captive Portal'; var port=80;var httpsport=443;var redirectTo='';var preserveCaptivePortal='Y';var guestUserEnabled = false;var myAccountLink = true;&lt;/script&gt;&lt;body style='background:#FFFFFF;font-family: Arial;font-size: 12px;color:#565656;'&gt;&lt;table width='100%' cellspacing='0' cellpadding='0'&gt;
  &lt;tr&gt;&lt;td height='50px;' style='color:#565656' align='center' valign='middle'&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;table width='100%'&gt;&lt;tr&gt;&lt;td align='center'&gt;
  &lt;div style='background: #FFFFFF;margin-top: 5%;box-shadow: 0px 0px 10px #666666;border: 1px solid #CCCCCC;width: 550px;height:375px;'&gt;&lt;form name='frmHTTPClientLogin' target='_parent' method='post' onSubmit='return checkSubmit();' action='httpclient.html'&gt;&lt;input type='hidden' value='191' name='mode'/&gt;&lt;table align='left' width='100%' cellpadding='0' cellspacing='0' style='text-align: left;'&gt;&lt;tr&gt;&lt;td colspan='5' height='15px'&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr bgcolor='#FFFFFF'&gt;&lt;td width='7%'&gt;&amp;nbsp;&lt;/td&gt;&lt;td colspan='2' style='color: #336699;font-size: 20px;font-weight: bold;'&gt;&lt;div style='margin-top: 15px;max-height: 50px;width: 245px;overflow: hidden;'&gt;KIIT Captive Portal&lt;/div&gt;&lt;/td&gt;&lt;td align='right'&gt;&lt;a href='http://www.kiit.ac.in' target='_new' &gt;&lt;img width='125' height='70' src='/images/customizeimages/uploadedwebclientlogo.jpg' name='logo' border='0' &gt;&lt;/a&gt;&lt;/td&gt;&lt;td width='7%'&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td colspan='3' height='45'&gt;&lt;div id='msgDiv'&gt;&lt;/div&gt;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td width='43%'&gt;&lt;table width='100%' cellpadding='0' cellspacing='3'&gt;&lt;tr id='usernamelbl'&gt;&lt;td style='color:#565656;font-weight: bold;font-size: 12px;'&gt;Username&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;input type='text' name='username' maxlength='50' style='border: 1px solid #CCCCCC;padding-top:3px;padding-bottom: 3px;width: 200px;' &gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr id='passwordlbl'&gt;&lt;td style='color:#565656;font-weight: bold;font-size: 12px;'&gt;Password&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;input type='password' name='password' autocomplete='off' style='border: 1px solid #CCCCCC;padding-top:3px;padding-bottom: 3px;width: 200px;'&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;input type='submit' name='btnSubmit' value='Login' id='logincaption' style='font-weight: bold;background-color: #AAAAAA;background-color:#BBBBBB; border: 1px solid #CCCCCC;font-weight: bold;min-width: 100px;padding-top:3px;padding-bottom: 3px;margin-top: 10px;color:#333333;font-size: 12px;' /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;td width='3%'  style='border-left:1px solid #CCCCCC'&gt;&amp;nbsp;&lt;div style='border-left:1px solid #CCCCCC'&gt;&lt;/div&gt;&lt;/td&gt;&lt;td width='40%'&gt;&lt;table width='100%' cellpadding='0' cellspacing='0' &gt;&lt;tr&gt;&lt;td&gt;&lt;ul&gt;&lt;li style='color: #565656;font-size: 12px;font-weight: bold;margin-left: -25px;' id='accountAncLI'&gt;&lt;a href='#' style='color: #565656;text-decoration: none;' target='_new'   
           id='accountAnc'&gt;Click here for User My Account&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;ul&gt;&lt;li  id='registerLinkLI' style='color: #565656;font-size: 12px;font-weight: bold;margin-left: -25px;'&gt;&lt;a href='#' style='color:#565656;text-decoration: none;' id='registerLink'&gt;Click here to get a username to access the Internet&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;ul&gt;&lt;li id='redirecturl' style='color: #565656;font-weight: bold;list-style:none;font-size: 12px;font-weight: bold;margin-left: -25px;'&gt;&lt;a href='#' style='color: #565656;text-decoration: none;' id='accountAnc'&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td colspan='5'&gt;&lt;div style='margin-left: 20px; margin-right: 20px; border-bottom: 1px solid #CCCCCC; width: 92%;*width: 100%;  height: 50px;'&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td colspan='5' height='20px'&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td colspan='5' align='center' style='font-weight: bold;color: #FD0000;font-size: 12px;display:none'&gt;Note : Do not close this window, closing this window will log you out.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td colspan='5' height='30px'&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
      &lt;table width='100%' cellspacing='0' cellpadding='0'&gt;&lt;tr&gt;&lt;td height='50px;' style='color:#565656' align='center' valign='middle'&gt;&lt;font color="green"&gt;&lt;b&gt;Once Authenticated with this portal please Download Authentication client for Windows from below Link:&lt;/b&gt;&lt;/font&gt; &lt;/br&gt;
  &lt;a href ="http://download.cyberoam.com/solution/optionals/Corporateclientsetup.exe" target="_blank"&gt;http://download.cyberoam.com/solution/optionals/Corporateclientsetup.exe&lt;/a&gt;&lt;br&gt;
  
  Notes:&lt;br&gt; 
  
  1. You won't be able to download the client without login into this portal.&lt;br&gt; 
  
  2. Server address on the client should be &lt;b&gt;&lt;u&gt;192.168.102.1&lt;/u&gt;&lt;/b&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;script language='JavaScript'&gt;loginValue = 'Login';logoutValue = 'Logout';setHREF();&lt;/script&gt;&lt;div id="arrivedMsgDiv" style="display:none"&gt;&lt;/div&gt;&lt;/form&gt;&lt;/body&gt;&lt;/html&gt;&lt;script language="Javascript"&gt;document.forms[0].password.setAttribute("maxLength",60);&lt;/script&gt;
  </code></pre>