[已解决]网络答题求助
本帖最后由 king8462 于 2013-12-6 20:19 编辑如下的网络答题页面,已经有答案数据库,想做个自动答题的脚本,水平有限,想请各位高人给点提示。万分感谢!
以下是页面文件:
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
<title>测试</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<style type="text/css">
#floater
{
position:absolute;
width:220px;
height:155px;
position:absolute;
top:100px;
z-index:1000;
background-color:#6699FF;
cursor:default;
text-align:center;
font-family:Verdana;
font-size:13px;
border:2px solid #6699FF;
left:542px;
display:none;
}
#floatTop
{
background-color:#6699FF;
width:100%;
height:20px;
color:white;
text-align:left;
padding-left:0px;
}
#timeHead
{
display:block;
float:left;
}
#minICon
{
padding-top:-2px;
border-width:0px;
color:white;
font-family:webdings;
padding-right:0px;
display:block;
float:right;
}
#time
{
width:216px;
height:134px;
text-align:left;
background-color:white;
line-height:14px;
color:#6699FF;
word-break:break-all;
padding-left:2px;
}
</style>
<link rel="stylesheet" type="text/css" href="styles.css">
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="json2.js"></script>
<script type="text/javascript">
var hasLeftSeconds = parseInt('90')*60;
var second ; // 计算秒
var minute;
var hour ;
var showHour;
var showMinute;
var showSecond;
var showLeftTime;
var _move=false;//移动标记
var _x=0,_y=0;//鼠标离控件左上角的相对位置
var idOfInterval;
function formatTime(seconds)
{
var formatTime='00:00:00';
if(seconds>=0)
{
/*var h=Math.floor((hasLeftSeconds / 3600) % 24);
var m=Math.floor((hasLeftSeconds / 60) % 60);
var s=Math.floor(hasLeftSeconds % 60);*/
var h=parseInt(seconds/3600);
var m=parseInt((seconds-h*3600)/60);
var s=parseInt(seconds-h*3600-m*60);
showLeftTime="";
if(h> 0)
{
showHour = " "+h+"小时 ";
showLeftTime += showHour;
}
if(m>0)
{
showMinute = " "+ m+"分 ";
showLeftTime += showMinute;
}
showLeftTime += " "+s+"秒 ";
$("#remainTime").html("<br/><span style='color:red;font-size:14px'>离考试结束还剩"+showLeftTime+"(到时间后将自动交卷)"+"</span>");
}
else
{
document.showPaperForm.submit();
window.clearInterval(hasLeftSeconds);
}
formatTime= '0'+h+':'+(m>9?m:'0'+m)+':'+(s>9?s:'0'+s);
return formatTime;
}
function showTime(totalMins)
{
var totalSecs = totalMins*60;
var begin = new Date().getTime();
var now = '<BR> '+new Date().toLocaleString()
+'<BR><BR> 考试时长:'
+totalMins+'分钟'+'<BR><BR> 已用时间:'
+formatTime((new Date().getTime()-begin)/1000)
+'<BR><BR> 剩余时间:'+formatTime(totalSecs-(new Date().getTime()-begin)/1000);
document.getElementById('time').innerHTML=now;
idOfInterval = setInterval("if(("+totalSecs+"-(new Date().getTime()-"+begin+")/1000)>0){document.getElementById('time').innerHTML='<BR> '+new Date().toLocaleString()+'<BR><BR> 考试时长:"+totalMins+"分钟'+'<BR><BR> 已用时间:'+formatTime(((new Date().getTime()-"+begin+")/1000))+'<BR><BR> 剩余时间:'+formatTime("+totalSecs+"-(new Date().getTime()-"+begin+")/1000);}else if(("+totalSecs+"-(new Date().getTime()-"+begin+")/1000)>-6){document.getElementById('time').innerHTML='<BR> <h3 align=center>考试结束!<br><br>试卷将在'+parseInt(6+("+totalSecs+"-(new Date().getTime()-"+begin+")/1000))+'秒后自动提交</h3><br>';} else{submitPaper();}",1000);
}
function a()
{
if(confirm("您确认要现在交卷吗?"))
{
submitPaper();
return false;
}
else
{
return false;
}
}
function submitPaper()
{
var questionCount=parseInt('50');
//alert(questionCount);
//alert('50');
//alert("ddd");
var questionTypeCount=parseInt('4');
var oneTypeQuestionCount;
var questionTypeNo;
var answersString="";
var StringId;
var questionIndex=0;
var chooseValue;
for(var j=0;j<questionTypeCount;j++)
{
questionTypeNo=parseInt(document.getElementsByName("questionTypeNo").value);
oneTypeQuestionCount=parseInt(document.getElementsByName("oneTypeQuestionCount").value);
for(var k=0;k<oneTypeQuestionCount;k++)
{
if(questionTypeNo==1 || questionTypeNo==4)
{
StringId = "input:checked";
if($(StringId).val())
answersString += $(StringId).val()+",";
else answersString += "|"+",";
}
else if(questionTypeNo==2 || questionTypeNo==3 )
{
StringId = "input:checked";
if($(StringId).val())
{
$(StringId).each(function(){
{
answersString += $(this).val();
}
});
}
else
{
answersString += "|";
}
answersString +=",";
}
else if(questionTypeNo==2 || questionTypeNo==3 )
{
StringId = "input:checked";
if($(StringId).val())
{
$(StringId).each(function(){
{
answersString += $(this).val();
}
});
}
else
{
answersString += "|";
}
answersString +=",";
}
questionIndex++;
}
}
answersString = answersString.substring(0,answersString.length-1);
$("#answers").val(answersString);
document.getElementById("submitPaper").disabled = true;
document.showPaperForm.submit();
window.clearInterval(idOfInterval);
}
function scrollAd()
{
//定义位移为floatdiv的高度加上滚动条的顶部距离
var offset =$('#floater').height() + $(document).scrollTop();
//为floatdiv添加动画为TOP位移offset的高度,持续0.8秒。
$('#floater').stop().animate({top:offset},800);
$('#floater').scrollLeft(document.body.offsetWidth);
}
$(function(){
var name = $('#floater');
showTime(parseInt('90'));
$(name).show();
$("#minICon").click(function(){
if($("#minICon").html()==0)
{
$("#time").hide();
$('#floater').height(20);
$("#minICon").html("2");
}
else
{
$("#time").show();
$('#floater').height(155);
$("#minICon").html("0");
}
});
$('#close').click(function(){
$(name).hide();
});
$("#floater").click(function(){
//alert("click");//点击(松开后触发)
}).mousedown(function(e){
_move=true;
_x=e.pageX-parseInt($("#floater").css("left"));
_y=e.pageY-parseInt($("#floater").css("top"));
$("#floater").fadeTo(20, 0.25);//点击后开始拖动并透明显示
});
var name = $('#floater');//滚动DIV的ID
var name2= $('#backdiv');
//为ID为close的DIV添加点击事件
$('#close').click(function(){
$(name).hide();
});
//定义一个名字为scrollAD的函数
$(window).scroll(scrollAd);
$(document).mousemove(function(e){
if(_move){
var x=e.pageX-_x;//移动时根据鼠标位置计算控件左上角的绝对位置
var y=e.pageY-_y;
$("#floater").css({"top":y,"left":x});//控件新位置
}
}).mouseup(function(){
_move=false;
$("#floater").fadeTo("fast", 1);//松开鼠标后停止移动并恢复成不透明
});
/*initialize(parseInt('90'));
var name = $('#floater');//滚动DIV的ID
var name2= $('#backdiv');
//为ID为close的DIV添加点击事件
$('#close').click(function(){
$(name).hide();
});
//定义一个名字为scrollAD的函数
function scrollAd()
{
//定义位移为floatdiv的高度加上滚动条的顶部距离
var offset =$(name).height() + $(document).scrollTop();
//为floatdiv添加动画为TOP位移offset的高度,持续0.8秒。
$(name).stop().animate({top:offset},800);
$(name2).stop().animate({top:offset},800);
}
$(window).scroll(scrollAd);*/
});
</script>
<script src="cnzz_2"></script><script src="cnzz_core.php" charset="utf-8" type="text/javascript"></script></head>
<body marginwidth="0">
<div id="floater" style="display: block; opacity: 1;">
<div id="floatTop">
<span id="timeHead"><img src="ico_clock.gif" alt="计时器"> 考试计时</span>
<span id="minICon">0</span>
<div style="clear:both"></div>
</div>
<div id="time"><br> 2013-11-28 22:10:10<br><br> 考试时长:90分钟<br><br> 已用时间:00:08:49<br><br> 剩余时间:01:21:10</div>
</div>
<div align="center" class="maindiv">
<br>
<br>
时间限制:90分钟 <div id="remainTime"><br><span style="color:red;font-size:14px">离考试结束还剩 1小时21分10秒 (到时间后将自动交卷)</span></div>
<br><br>
<div align="left" style="padding-left:40px">
<form name="showPaperForm" id="showPaperForm" action="http://www.aaa.cn/cs/" method="post">
<table width="800" height="52" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td height="40">
<h3><b>一、单项选择题(共1小题,每小题1分)</b></h3>1.佛教流传到中国的时间是( )
</td>
</tr>
<tr>
<td height="40">
<input id="question0" name="question0" type="radio" value="A">A西汉初年
</td>
</tr>
<tr>
<td height="40">
<input id="question0" name="question0" type="radio" value="B">B西汉末年
</td>
</tr>
<tr>
<td height="40">
<input id="question0" name="question0" type="radio" value="C">C东汉初年
</td>
</tr>
<tr>
<td height="40">
<input id="question0" name="question0" type="radio" value="D"> D东汉末年
</td>
</tr>
</tbody></table>
<table width="800" height="52" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td height="40">
</td>
</tr>
</tbody></table>
<table width="800" height="52" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td height="40">
<h3><b>二、多项选择题(共1小题,每小题3分)</b></h3>1.宋明理学的学术渊源是
</td>
</tr>
<tr>
<td height="40">
<input id="question15" name="question15" type="checkBox" value="A">A.儒家学说
</td>
</tr>
<tr>
<td height="40">
<input id="question15" name="question15" type="checkBox" value="B">B.道家学说
</td>
</tr>
<tr>
<td height="40">
<input id="question15" name="question15" type="checkBox" value="C">C.佛教学说
</td>
</tr>
<tr>
<td height="40">
<input id="question15" name="question15" type="checkBox" value="D"> D.法家学说
</td>
</tr>
</tbody></table>
<table width="800" height="52" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td height="40">
</tbody></table>
<table width="800" height="52" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td height="40">
<h3><b>四、判断题(共1小题,每小题1分)</b></h3>1.鲁迅的第一篇白话文小说是《狂人日记》
</td>
</tr>
<tr>
<td height="40">
<input id="question35" name="question35" type="radio" value="1"> 对
<input id="question35" name="question35" type="radio" value="0"> 错
</td>
</tr>
</tbody></table>
<table width="800" height="52" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td height="40">
</tbody></table>
<input type="hidden" name="questionTypeNo" id="questionTypeNo" value="1">
<input type="hidden" name="oneTypeQuestionCount" id="oneTypeQuestionCount" value="15">
<input type="hidden" name="questionTypeNo" id="questionTypeNo" value="2">
<input type="hidden" name="oneTypeQuestionCount" id="oneTypeQuestionCount" value="10">
<input type="hidden" name="questionTypeNo" id="questionTypeNo" value="3">
<input type="hidden" name="oneTypeQuestionCount" id="oneTypeQuestionCount" value="10">
<input type="hidden" name="questionTypeNo" id="questionTypeNo" value="4">
<input type="hidden" name="oneTypeQuestionCount" id="oneTypeQuestionCount" value="15">
<input type="hidden">
<input type="hidden" name="answers" id="answers">
<input type="hidden" name="selectCourseId" id="selectCourseId" value="12345">
<center><input id="submitPaper" type="button" value="交卷" onclick="return a()"></center>
</form>
</div>
</div>
</body></html> 这个以前有例子 好古老的问题了,搜索一下 搜到这个链接,http://www.autoitx.com/forum.php?mod=viewthread&tid=36182&highlight=%B4%F0%CC%E2
但活动已经结束,看不到http://hd.31597.cn/mls/event.php?t=qu这个页面了。 这种答题页面,模拟点击好,还是post,请高人给点指引啊。 这个也能做成自动的? 对autoit来说太简单。模拟点击就行。 感谢各位,已通过模拟点击解决。
页:
[1]