模拟登陆网站如何跳转。


我尝试模拟登陆学校的教务网,自己遇到了一些我不能解决的问题。


 <script>window.open('xs_main.aspx?xh=xxxxxxxx','_parent');</script>
<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
        <HEAD>
                <title>现代教务管理系统-->WEB登录</title><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
                <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
                <meta content="True" name="vs_showGrid">
                <meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
                <meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
                <meta content="JavaScript" name="vs_defaultClientScript">
                <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
                <LINK href="Default.css" type="text/css" rel="stylesheet">
        </HEAD>
        <body leftMargin="0" background="tpml/BKGRD9.JPG" topMargin="0" scroll="no" MS_POSITIONING="GridLayout">
                <form name="form1" method="post" action="default_ysdx.aspx?__VIEWSTATE=dDw1MjQ2ODMxNzY7Oz5pEk%2FdqkpVDLoTnyvjiXNSAh3
jVg%3D%3D&TextBox2=19951031qxq&RadioButtonList1=%E5%AD%A6%E7%94%9F&TextBox1=14263319&__VIEWSTATEGENERATOR=701681CC&a
mp;Button1=%E7%99%BB%E5%BD%95" id="form1">
<input type="hidden" name="__VIEWSTATE" value="dDw1MjQ2ODMxNzY7Oz5pEk/dqkpVDLoTnyvjiXNSAh3jVg==" />

<input type="hidden" name="__VIEWSTATEGENERATOR" value="701681CC" />

                        <TABLE id="Table3" height="250" cellSpacing="0" cellPadding="0" width="309" align="left"
                                border="0">
                                <TR>
                                        <TD style="WIDTH: 315px">
                                                <table id="Table1" style="BORDER-RIGHT: #b0b0b0 1pt outset; PADDING-RIGHT: 10px; BOR
DER-TOP: #b0b0b0 1pt outset; PADDING-LEFT: 10px; BACKGROUND: #ffffff; FILTER: progid: DXImageTransform.Microsoft.dropshadow(OffX=5,
OffY=5, Color='#CCCCCC', Positive='true'); PADDING-BOTTOM: 10px; BORDER-LEFT: #b0b0b0 1pt outset; WIDTH: 312px; PADDING-TOP: 10px; B
ORDER-BOTTOM: #b0b0b0 1pt outset; HEIGHT: 230px"
                                                        cellSpacing="0" cellPadding="4" border="0">
                                                        <TR height="3">
                                                                <TD style="HEIGHT: 2px" noWrap width="50" bgColor="#00ae5c"></TD>
                                                                <TD style="HEIGHT: 2px" noWrap width="30" bgColor="#f7b61a"></TD>
                                                                <TD style="HEIGHT: 2px" noWrap width="45" bgColor="#e23845"></TD>
                                                                <TD style="HEIGHT: 2px" noWrap width="225" bgColor="#333333"></TD>
                                                        </TR>
                                                        <TR>
                                                                <TD vAlign="middle" align="center" colSpan="4">
                                                                        <TABLE style="WIDTH: 201px; HEIGHT: 138px" cellPadding="5" w
idth="201">
                                                                                <TR>
                                                                                        <TD style="PADDING-LEFT: 10pt" noWrap><span
id="Label1">用户名称:</span><input name="TextBox1" type="text" value="14263319" id="TextBox1" tabindex="1" class="InputBox" /></TD>

                                                                                </TR>
                                                                                <TR>
                                                                                        <TD style="PADDING-LEFT: 10pt" noWrap><span
id="Label2">用户口令:</span><input name="TextBox2" type="password" id="TextBox2" tabindex="2" class="InputBox" /></TD>
                                                                                </TR>
                                                                                <TR>
                                                                                        <TD style="PADDING-LEFT: 10pt" noWrap><table
 id="RadioButtonList1" border="0" width="100%">
        <tr>
                <td><input id="RadioButtonList1_0" type="radio" name="RadioButtonList1" value="部门" tabindex="3" /><label for="Radi
oButtonList1_0">部门 </label></td><td><input id="RadioButtonList1_1" type="radio" name="RadioButtonList1" value="教师" tabindex="3"
 /><label for="RadioButtonList1_1">教师 </label></td><td><input id="RadioButtonList1_2" type="radio" name="RadioButtonList1" value=
"学生" checked="checked" tabindex="3" /><label for="RadioButtonList1_2">学生 </label></td><td><input id="RadioButtonList1_3" type="
radio" name="RadioButtonList1" value="访客" tabindex="3" /><label for="RadioButtonList1_3">访客 </label></td>
        </tr>
</table></TD>
                                                                                </TR>
                                                                                <TR>
                                                                                        <TD style="PADDING-LEFT: 10pt" align="center
"><input type="submit" name="Button1" value="  登录  " id="Button1" class="Button1" /><input type="submit" name="Button2" value="
关闭  " id="Button2" class="Button1" onclick="window.close();" /></TD>
                                                                                </TR>
                                                                        </TABLE>
                                                                </TD>
                                                        </TR>
                                                        <TR>
                                                                <TD style="PADDING-BOTTOM: 7pt; PADDING-TOP: 7pt" align="left" colSp
an="4" height="100%"><table id="Panel1" cellpadding="0" cellspacing="0" border="0" width="320"><tr><td>
        注意事项:<B>
                                                                                        访客请直接登录,使用完毕请关闭浏览器</B>
</td></tr></table></TD>
                                                        </TR>
                                                </table>
                                        </TD>
                                </TR>
                        </TABLE>
                </form>
        </body>
</HTML>

我根据 <script>window.open('xs_main.aspx?xh=xxxxxxxx','_parent');</script> 判定自己已经登陆成功了(可能是我自己想错了),我自己不了解js的知识,只是知道这是新打开一个的窗口,由于网站没有cookie和session(在chrome的工具中一个一个检查没有发现),我没有办法依靠网上的那些方法解决这个问题。希望有经验的朋友可以帮忙解决一下。

python3.x 网页爬虫

zglzs 9 years, 6 months ago

这是正方的教务系统吧!!
你使用的哪种方式进行的模拟登录。
如果是PHP, curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); 可以实现

如果是Python,有这个库 cookielib


 cookie = cookielib.LWPCookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie))
urllib2.install_opener(opener)
opener.open(baseUrl)

他们都是可以设置携带session进行请求的。

人间妹控是沧桑 answered 9 years, 6 months ago

Your Answer