本帖最后由 afan 于 2009-9-29 22:11 编辑
修改了下#include <IE.au3>
$file = FileOpen("zi.txt", 0)
If $file = -1 Then
MsgBox(0, "错误", "在脚本目录下建立zi.txt的文本文件在写几个汉字")
Exit
EndIf
While 1
$chars = FileRead($file, 2)
If @error = -1 Then ExitLoop
$oIE = _IECreate("http://www.uname.cn/html/dic/4/63_9084.shtml")
$a = _IEGetObjByName($oIE, "Query")
_IEFormElementSetValue($a, $chars);账号
$oSubmit = _IEGetObjByName($oIE, "Query")
WinWaitActive("在线字典")
_IEAction($oSubmit, "focus")
Send("{enter}")
_IEQuit($oIE)
WinWait("在线字典", "完毕")
If Not WinActive("在线字典", "完毕") Then WinActivate("在线字典", "完毕")
Sleep(2000)
WinWaitActive("在线字典", "完毕")
$var = ControlGetText("在线字典", "", "Edit1")
WinClose("在线字典", "完毕")
ProcessClose("IEXPLORE.EXE")
$oIE2 = _XmlHttp($var)
$sR = StringRegExp($oIE2, '#FFFFFF">(.*?)( )?</td>', 3)
If @error = 0 Then
IniWrite("a2.ini", "Section3", $chars, $sR[0] & "," & $sR[2] & "," & $sR[3] & "," & $sR[4] & "," & $sR[6] & "," & $sR[7] & "," & $sR[8] & "," & $sR[9])
EndIf
WEnd
Func _XmlHttp($Url) ;Sanhen
Local $oHTTP, $sReturn
$oHTTP = ObjCreate("microsoft.xmlhttp")
$oHTTP.Open("get", $Url, False)
$oHTTP.Send()
$sReturn = BinaryToString($oHTTP.responseBody)
Return $sReturn
EndFunc ;==>_XmlHttp
还是改用microsoft.xmlhttp靠得住,以下是部分测试的结果,没继续测试
[Section3]
金=金,jīn,gam1,金,金,8,8,金
镇=镇,zhèn,zan3,鎮,钅,18,15,金
锁=锁,suǒ,so2,鎖,钅,18,12,金
镕=镕,róng,jung4,鎔,钅,18,15,金
镉=镉,gé,gaak3,鎘,钅,18,15,金
镑=镑,bàng,bong2、bong6,鎊,钅,18,15,金
镈=镈,bó,bok3,鎛,钅,24,15,金
镐=镐,gǎo,hou6,鎬,钅,18,15,金 |