gpt4 book ai didi

javascript - 使用 Python 获取 DHCP 客户端列表

转载 作者:行者123 更新时间:2023-11-28 22:39:46 24 4
gpt4 key购买 nike

我目前正在编写一个 python 脚本,该脚本需要我在本地路由器的 DHCP 服务器上获取当前客户端的列表。关于如何做到这一点,我的第一个想法是使用 requests获取包含列表的网页 (http://192.168.2.1/lan_dhcp.stm) 然后解析数据并使用它。

问题是,有时路由器的网络界面会要求我登录,即使没有设置密码,您只需点击提交即可。如何通过 Python 发送登录请求 (http://192.168.2.1/login.htm) 以保证我能够访问客户列表?也许有更好的方法来做到这一点? The login screen with a look at the network登录.cgi:

<html><head><META http-equiv="Content-Type" content="text/html; charset=UTF-8" ></head><script>
function reload(){ top.topFrame.location.href=top.topFrame.location.href; document.location.href="lan_dhcp.stm";}
setTimeout("reload()", 900);
</script></html>

形成网页的一部分

<form action="login.cgi" method="post" name="tF" onsubmit="checkfwVersion()">
<input type="hidden" name="totalMSec" value="">
<input type="hidden" name="pws" value="">
<input type="hidden" name="arc_action" value="login">
<table border="0" cellspacing="0" cellpadding="0" align="left" width="100%" height="100%">
<tbody>
<tr>
<td valign="top" width="99%" height="100%" class="head_bold">
<br>
<font color="#0000ff">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Login</font>
<br>
<!--This is Login.stm-->
<table border="0" class="copy_1">
<tbody>
<tr>
<td width="5" colspan="2">&nbsp;</td>
</tr>
<tr>
<td width="5">&nbsp;</td>
<td>
<table width="480" border="0" cellspacing="5" cellpadding="0" align="left" class="copy_1">
<tbody>
<tr>
<td width="69" height="41">&nbsp;</td>
<td height="41" class="body" colspan="2">
Before you can change any settings, you need to login with a password. If you have
not yet set a custom password,
then leave this field blank and
click "Submit."
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="69">&nbsp;</td>
<td width="146" class="body"><b>Password</b>
</td>
<td width="250">
<input type="password" maxlength="12" size="16" name="pws_temp">
</td>
</tr>
<tr>
<td width="69" class="body">&nbsp;</td>
<td colspan="2">
<font color="#6F4AFD"><b>Default = leave blank</b></font>
</td>
</tr>
<tr>
<td width="69" colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="69">&nbsp;</td>
<td colspan="2" align="center">
<nobr>
<input type="button" onclick="javascript:document.tF.reset();" value="Clear" style="{width=120px;height=22px;}"
class="submitBtn" onmouseover="window.status='Clear'; return true;"
onmouseout="window.status=''; return true;"> &nbsp;&nbsp;
<input type="submit" name="action" value="Submit" style="{width=120px;height=22px;}"
class="submitBtn">
</nobr>
</td>


</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</form>

最佳答案

浏览器中似乎正在执行一些客户端 javascript 代码 - 查看您的 pws_temp 密码值如何转换为 pws 加密值:

enter image description here

requests 不是浏览器,也没有内置 javascript 引擎。

关于javascript - 使用 Python 获取 DHCP 客户端列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34405808/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com