如何使用python登录网站(wifi登录页面)?

2024-04-26 13:47:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用python登录到wifi登录页面,使用一组用户名和密码,以防帐户的数据限制自动结束。有人能帮我吗?在

脚本应该自动检查数据限制是否超过,然后使用下一组用户名和密码登录。在

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>              
<title>Captive Portal</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="expires" content="-1"/>
<script language="JavaScript" src="/javascript/cyberoamAjax.js"></script>
<script language="JavaScript">
var message = "";
var status = "LOGIN";
var ack = "";
var userName = "";
userName = userName.replace(new RegExp("''", 'g'),"'")
var password = "";
var timer="";
var liveReqTimeInJS=180;
</script>
<script language="JavaScript" src="/javascript/validation/httpclient.js?ver=60223"></script><link rel="stylesheet" href="/css/cyberoam.css?ver=47600" /></head><script language='JavaScript'>document.title='KIIT Captive Portal'; var port=80;var httpsport=443;var redirectTo='';var preserveCaptivePortal='Y';var guestUserEnabled = false;var myAccountLink = true;</script><body style='background:#FFFFFF;font-family: Arial;font-size: 12px;color:#565656;'><table width='100%' cellspacing='0' cellpadding='0'>
<tr><td height='50px;' style='color:#565656' align='center' valign='middle'></td></tr></table><table width='100%'><tr><td align='center'>
<div style='background: #FFFFFF;margin-top: 5%;box-shadow: 0px 0px 10px #666666;border: 1px solid #CCCCCC;width: 550px;height:375px;'><form name='frmHTTPClientLogin' target='_parent' method='post' onSubmit='return checkSubmit();' action='httpclient.html'><input type='hidden' value='191' name='mode'/><table align='left' width='100%' cellpadding='0' cellspacing='0' style='text-align: left;'><tr><td colspan='5' height='15px'>&nbsp;</td></tr><tr bgcolor='#FFFFFF'><td width='7%'>&nbsp;</td><td colspan='2' style='color: #336699;font-size: 20px;font-weight: bold;'><div style='margin-top: 15px;max-height: 50px;width: 245px;overflow: hidden;'>KIIT Captive Portal</div></td><td align='right'><a href='http://www.kiit.ac.in' target='_new' ><img width='125' height='70' src='/images/customizeimages/uploadedwebclientlogo.jpg' name='logo' border='0' ></a></td><td width='7%'>&nbsp;</td></tr><tr><td>&nbsp;</td><td colspan='3' height='45'><div id='msgDiv'></div></td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td width='43%'><table width='100%' cellpadding='0' cellspacing='3'><tr id='usernamelbl'><td style='color:#565656;font-weight: bold;font-size: 12px;'>Username</td></tr><tr><td><input type='text' name='username' maxlength='50' style='border: 1px solid #CCCCCC;padding-top:3px;padding-bottom: 3px;width: 200px;' ></td></tr><tr id='passwordlbl'><td style='color:#565656;font-weight: bold;font-size: 12px;'>Password</td></tr><tr><td><input type='password' name='password' autocomplete='off' style='border: 1px solid #CCCCCC;padding-top:3px;padding-bottom: 3px;width: 200px;'></td></tr><tr><td><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;' /></td></tr></table></td><td width='3%'  style='border-left:1px solid #CCCCCC'>&nbsp;<div style='border-left:1px solid #CCCCCC'></div></td><td width='40%'><table width='100%' cellpadding='0' cellspacing='0' ><tr><td><ul><li style='color: #565656;font-size: 12px;font-weight: bold;margin-left: -25px;' id='accountAncLI'><a href='#' style='color: #565656;text-decoration: none;' target='_new'   
         id='accountAnc'>Click here for User My Account</a></li></ul></td></tr><tr><td><ul><li  id='registerLinkLI' style='color: #565656;font-size: 12px;font-weight: bold;margin-left: -25px;'><a href='#' style='color:#565656;text-decoration: none;' id='registerLink'>Click here to get a username to access the Internet</a></li></ul></td></tr><tr><td><ul><li id='redirecturl' style='color: #565656;font-weight: bold;list-style:none;font-size: 12px;font-weight: bold;margin-left: -25px;'><a href='#' style='color: #565656;text-decoration: none;' id='accountAnc'></a></li></ul></td></tr></table></td><td>&nbsp;</td></tr><tr><td colspan='5'><div style='margin-left: 20px; margin-right: 20px; border-bottom: 1px solid #CCCCCC; width: 92%;*width: 100%;  height: 50px;'></div></td></tr><tr><td colspan='5' height='20px'>&nbsp;</td></tr><tr><td colspan='5' align='center' style='font-weight: bold;color: #FD0000;font-size: 12px;display:none'>Note : Do not close this window, closing this window will log you out.</td></tr><tr><td colspan='5' height='30px'>&nbsp;</td></tr></table></div></td></tr></table>
    <table width='100%' cellspacing='0' cellpadding='0'><tr><td height='50px;' style='color:#565656' align='center' valign='middle'><font color="green"><b>Once Authenticated with this portal please Download Authentication client for Windows from below Link:</b></font> </br>
<a href ="http://download.cyberoam.com/solution/optionals/Corporateclientsetup.exe" target="_blank">http://download.cyberoam.com/solution/optionals/Corporateclientsetup.exe</a><br>

Notes:<br> 

1. You won't be able to download the client without login into this portal.<br> 

2. Server address on the client should be <b><u>192.168.102.1</u></b><br></td></tr></table><script language='JavaScript'>loginValue = 'Login';logoutValue = 'Logout';setHREF();</script><div id="arrivedMsgDiv" style="display:none"></div></form></body></html><script language="Javascript">document.forms[0].password.setAttribute("maxLength",60);</script>

Tags: dividstylevartablescriptwidthtr
1条回答
网友
1楼 · 发布于 2024-04-26 13:47:56

在我看来,你首先需要了解网站是如何登录的。我看到它调用了一个函数checkSubmit。在

我们知道它是通过一个httppost来实现的。在

<form name='frmHTTPClientLogin' target='_parent' method='post' onsubmit='return checkSubmit();' action='httpclient.html' id="frmHTTPClientLogin">

所以你应该向网站发出POST请求,参数可能是登录名和密码。所以下一个任务是找出你必须在帖子中提供的键名(查找name=,用户名和密码)。在

^{pr2}$

还有其他input元素,我不知道您是否需要提供这些元素。在

你怎么打电话的?在

payload = {'username': 'value1', 'password': 'value2'}
r = requests.get("theurl", params=payload)

下一步是解析返回的HTML,可以在Python中使用库BeautifulSoup。在

相关问题 更多 >