找回密码
 加入
搜索
查看: 9786|回复: 24

[IE类操作] 谁能给个答题器的思路?

 火.. [复制链接]
发表于 2010-9-20 22:52:06 | 显示全部楼层 |阅读模式
如,这个消防答题。
http://aspnet.zjol.com.cn/XFDT/GGDT.aspx

如果直接要代码,显示太过份了。只是一直很少接触IE这一块,所以连个思路都没有。
哪位兄弟给个思路,或者大家一起讨论一下!

谢谢。
发表于 2010-9-21 09:00:43 | 显示全部楼层
回复 1# itljl


    那上面的题是随机的吧
 楼主| 发表于 2010-9-21 10:34:57 | 显示全部楼层
回复 2# guland


    随机的这个不用去管他,只想知道如何实现,判断题,然后选择单选,最后提交。
发表于 2010-9-21 13:36:20 | 显示全部楼层
回复 3# itljl
1、生成一个INI题库。
     字段[题目]中指定题的内容,
     字段[选择N]中指定题的可选择答案,
     字段[答案]为题的答案,唯一值
2、取随机数(相当于选题)
3、取随机数(相当于可选择答案数量)
xxx.ini
[题目]
1=a+b
2=b+c
..
[选择1]
1=c
2=d
3=f
4=g
[选择2]
1=c
2=d
3=f
4=g
...
[答案]
1=c
2=f
...
 楼主| 发表于 2010-9-21 16:02:32 | 显示全部楼层
回复 4# 3mile


    感谢这位兄弟的回复。,这些我都会。
主要是怎样操作这个网页。对这个网页内的内容进行题目判断,
如第一题,
第一题的问题。
第一题有几个单选框,然后选定单选框,这些对网页操作的问题。
发表于 2010-9-21 16:05:53 | 显示全部楼层
这个嘛!我不会!帮顶一下!希望高手能帮到楼主!
发表于 2010-9-21 21:06:43 | 显示全部楼层
回复 1# itljl


    给你找出点规律了,但是还得你去研究,看下面的网页代码片段
不知道我的解释你能不能看明白
http://zjnews.zjol.com.cn/05zjne ... /30/016888769.shtml
我是根据这个题库分析的,下面代码中我有给你解释
<form method="post"  name="frmvote" onsubmit="return(validate())">
<table width="85%" border="0" cellpadding="0" cellspacing="0" class="kuang">
      <tr>
        <td height="650" valign="top" class="back2"><table width="85%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td><p class="titlebig">第一关</p></td>
          </tr>
          <tr>
            <td>
      
      <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td align="left" class="px14">
              1. 《浙江省消防条例》是由【 】审议通过的。<input id='da1' name='da1' style="width: 33px"  type="hidden" value="20" /> ;value="20"就是题号,但是他好像故意打乱了顺序,目前为止40以下的,减去18就是真正的题号,40以上因为我刷新了N次也没刷新出来,只刷新出了80以上,80以上的就减去19就是真正的题号了......
          </td>
        </tr>
        <tr>
;从这开始就是答案了,不用判断有多少答案,因为上面已经判断出题了,所以答案是固定的,
          <td align="left" class="px14"><input type="radio" style="" name="rbr1" id="Radio1" value="A" />
因为控件ID是固定的,第几个答案是正确就直接选第几个就可以了
              A. 浙 江 省 人 民 政 府</td>
        </tr>
        <tr>
          <td align="left" class="px14"><input type="radio" style=""  name="rbr1" id="radio4" value="B" />
              B. 浙 江 省 人 民 代 表 大 会 常 务 委 员 会</td>
        </tr>
        <tr>
          <td align="left" class="px14"><input type="radio" style=""  name="rbr1" id="radio5" value="C" />
              C. 浙 江 省 人 民 代 表 大 会</td>
        </tr>
        <tr>
          <td align="left" class="px14"><input type="radio" style="display:none" name="rbr1" id="Radio6" value="" />
              </td>
        </tr>
        <tr>
          <td align="left" class="px14"><input type="radio" style="display:none"  name="rbr1" id="Radio7" value="" />
              </td>
        </tr>
        <tr height="10"></tr>
      </table>
      

      <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td align="left" class="px14">
              2. 《浙江省消防条例》规定,工会、共产主义青年团、妇女联合会等团体应当[   ]组织开展消防宣传教育。
<input id='da2' name='da2' style="width: 33px"  type="hidden" value="40" />
          </td>
        </tr>
        <tr>
          <td align="left" class="px14"><input type="radio" style="" name="rbr2" id="Radio1" value="A" />
              A. 发挥各自优势</td>
        </tr>
        <tr>
          <td align="left" class="px14"><input type="radio" style=""  name="rbr2" id="radio4" value="B" />
              B. 根据实际</td>
        </tr>
        <tr>
          <td align="left" class="px14"><input type="radio" style=""  name="rbr2" id="radio5" value="C" />
              C. 结合各自工作对象的特点</td>
        </tr>
        <tr>
          <td align="left" class="px14"><input type="radio" style="display:none" name="rbr2" id="Radio6" value="" />
              </td>
        </tr>
        <tr>
          <td align="left" class="px14"><input type="radio" style="display:none"  name="rbr2" id="Radio7" value="" />
              </td>
        </tr>
        <tr height="10"></tr>
      </table>
发表于 2010-9-22 00:52:38 | 显示全部楼层
实在不行,把题目放到数据库中,答题时候,自动查询数据库,选择正确答案答题

我有发过一篇,600来道题目
 楼主| 发表于 2010-9-22 15:14:57 | 显示全部楼层
回复 8# bob


    谢谢这些逻辑和功能上的实现都会的。

只是不知道如何读取网页上的这个题目,和答案,以及如何去点击那个正确的单选按钮。有相应的例子吗?
发表于 2010-9-22 21:07:02 | 显示全部楼层
有答案一起来看看哦!
发表于 2010-9-22 21:33:48 | 显示全部楼层
我进来学习哦
发表于 2010-9-22 22:28:09 | 显示全部楼层
本帖最后由 rolaka 于 2010-9-22 23:06 编辑


#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <ie.au3>

Global $data[1]
referData()

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 1001, 447, 192, 124)
$Group1 = GUICtrlCreateGroup("Group1", 744, 10, 241, 345)
$Edit1 = GUICtrlCreateEdit("", 760, 32, 209, 305, BitOR($ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_VSCROLL))
GUICtrlSetData(-1, "Edit1")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Button1", 744, 368, 241, 65)
$oIE = _IECreateEmbedded()
$ActiveX = GUICtrlCreateObj($oIE, 16, 16, 708, 418)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
_IENavigate($oIE, "http://wmzsjs.eastday.com/channel/game2/register.asp")
;~ _IEDocWriteHTML($oIE, FileRead("2"))

While 1
        _IELoadWait($oIE)
        $oDoc = _IEDocGetObj($oIE)
        If StringInStr($oDoc.url, "answer.asp") Then
;~                 MsgBox(0, "setp", "1")
                $test = _IEBodyReadHTML($oIE)
;~                 FileWrite("2", $test)
                If StringRight($test, 1) <> "1" Then
;~                         MsgBox(0, "setp", "2")
                        _IEBodyWriteHTML($oIE, $test & "1")
                        $answer = StringRegExp($test, "<SPAN class=STYLE8>\s*(.+)\s+</SPAN>", 3)
;~                         _ArrayDisplay($answer)
                        If @error <> 0 Then
;~                                 MsgBox(0, "", @error)
                                _ArrayDisplay($answer)
                        EndIf
                        $key = searchAnswer($answer[0])
                        $flag = 0
;~                         MsgBox(0, "", $key)
                        If $key <> "" Then
;~                                 MsgBox(0, "setp", "3")
;~                                 MsgBox(0, "", $key)
                                For $i = 1 To UBound($answer)
;~                                         MsgBox(0, StringInStr($answer[$i], $key), $answer[$i]&" "&$key)
                                        If StringInStr($answer[$i], $key) Then
;~                         If StringInStr($answer[$i], $key) And (StringLen($answer[$i])-StringLen($key)) < 10 Then
                                                $htmlName = StringRegExp($test, 'value=(\d+) type=radio name=ChkAns> </TD>\s+<TD width="97%"><SPAN class=STYLE8>.+?' & $key, 3)
                                                If @error <> 0 Then
                                                        $flag = 2
                                                        ExitLoop
                                                Else
                                                        $flag = 0
                                                        $oForm = _IEFormGetObjByName($oIE, "AnswerForm")
                                                        _IEFormElementRadioSelect($oForm, $htmlName[0], "ChkAns", 1)
                                                        _IENavigate($oIE, "javascript:checkForm()", 1)
                                                        MsgBox(0, $htmlName[0], $htmlName[0])
                                                        ExitLoop
                                                EndIf
                                        EndIf
                                Next
                        Else
                                $flag = 1
                        EndIf
                        If $flag Then
                                MsgBox(0, "检索失败", "请手动答题...")
                        EndIf
                EndIf
        EndIf
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        referData()
        EndSwitch
WEnd

Func searchAnswer($answer)
;~         $index = _ArraySearch($data, clearVal($answer), 0, 0, 0, 0, 0, 1)
        For $i = 0 To UBound($data) - 1
                ConsoleWrite($data[$i][0] & "|" & $answer & "|" & StringInStr(clearVal($answer), $data[$i][0]) & "|" & @CRLF)
                If StringInStr($data[$i][0], clearVal($answer)) Or StringInStr(clearVal($answer), $data[$i][0]) Then
                        Return clearVal($data[$i][1])
                EndIf
        Next
        Return ""
EndFunc   ;==>searchAnswer

Func clearVal($val)
        Return StringStripWS($val, 3)
EndFunc   ;==>clearVal

Func referData()
        $fp = FileOpen("data.txt")
        Global $data[1]
        While 1
                $line = FileReadLine($fp)
                If @error <> 0 Then
                        ExitLoop
                EndIf
                $key = StringSplit($line, "|", 2)
                $index = UBound($data)
                ReDim $data[$index + 1][2]
                $data[$index][0] = $key[0]
                $data[$index][1] = $key[1]
        WEnd
        _ArrayDelete($data, 0)
EndFunc   ;==>referData
=.= 以前写的 测试版 实际用还有点小问题...

很乱...
填写身份证信息 -(提交)-> 当地址里包含answer.asp时候 匹配题目+搜索答案+匹配正确项的name -(选择正确的项目+提交表单)-> 等待加载完毕 返回第二步
后面答题完毕了之后处理的部分没有写 因为从来就没能正常答到最后..............................................

附件是题库

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2010-9-22 22:37:43 | 显示全部楼层
这个值得学习
发表于 2010-9-23 01:03:57 | 显示全部楼层
直接套这个网页进去窗口里面.....

=。=如果是我做,我会选择数据库方式。
发表于 2010-9-23 07:56:23 | 显示全部楼层
回复 1# itljl


    发现了一个漏洞,哈哈,看来可以做个作弊工具了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-17 07:04 , Processed in 0.086782 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表