带有Javascrip的Python登录表单

2024-09-30 20:32:28 发布

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

我想获取站点“https://xxxxxx/login.htmx”的内容。在html代码中有一个JS脚本,如下所示:

<script language="javascript">$(document).ready(function() {
$('#BTN_ACCEDI').linkbutton({plain:false});
$('#BTN_ACCEDI').click(function(){customSubmitLogin();});
$('#j_password').validatebox({required:true,validType:'length[1,80]' });
$('#j_username').validatebox({required:true,validType:'length[1,80]'});     
$('#imp_num').validatebox({required:true,validType:'length[1,5]'});     
 $('#j_username').focus();
});</script>

我一直在寻找,所以我找到了一些线索:

^{pr2}$

但是当我尝试r.text时,它会给我原始的html页面,而不是登录后的页面。
你能帮我吗?知道成功登录后的URL是相同的有用吗?在


Tags: httpstrue站点htmlrequiredusernamescriptfunction
1条回答
网友
1楼 · 发布于 2024-09-30 20:32:28

您需要更多表单数据:

import requests

data = {"dispatch": "toWelcomePage",
        "j_username": "username",
        "j_password": "youpass",
        "imp_num": "num",
        "enteSel": "num"}
with requests.session() as s:
    r = s.post("https://www.sic.ania.it/login.htmx", data=data)

如果您查看“打开开发人员工具”,您可以看到从浏览器提交时发布的内容:

enter image description here

相关问题 更多 >