|
取值用的,取到50个左右$s这个变量就出问题了。一直为一个值。也就是说它每次都是一个数值了。
还有一个,这段代码还有什么其他更稳定的方法吗? $sHTML = _IEBodyReadHTML($oIE)
$Link = StringRegExp($sHTML, 'href="(/html/dic/[^"]+)">', 3)
If @error = 0 Then
$s = 'http://www.uname.cn' & $Link[0]
Else
IniWrite("e1cw.ini", $chars, @YEAR & "-" & @MON & "-" & @MDAY & "-" & @HOUR & "-" & @MIN & " 步骤5-这将是个错误回馈,而且也会因此停止程序的运行", $s)
EndIf
因为我估计不是这段代码的原因就是这段 $a = _IEGetObjByName($oIE, "gb")
_IEFormElementSetValue($a, $chars)
$oSubmit = _IEGetObjByName($oIE, "gb")
$b = _IEGetObjByName($oIE, "Submit")
_IEAction($b, "click")
_IELoadWait($oIE)
总代码#include <IE.au3>
#include <Constants.au3>
#include <Date.au3>
$file = FileOpen("zi.txt", 0)
If $file = -1 Then
MsgBox(0, "错误", "在脚本目录下建立zi.txt的文本文件在写几个汉字")
Exit
EndIf
$sl = 0
While 1
$chars = FileRead($file, 2)
$oIE = _IECreate("http://www.uname.cn/dic/zidian.asp", 1, 0,1,1)
Sleep(1000)
$a = _IEGetObjByName($oIE, "gb")
_IEFormElementSetValue($a, $chars)
$oSubmit = _IEGetObjByName($oIE, "gb")
$b = _IEGetObjByName($oIE, "Submit")
_IEAction($b, "click")
_IELoadWait($oIE)
$sHTML = _IEBodyReadHTML($oIE)
$Link = StringRegExp($sHTML, 'href="(/html/dic/[^"]+)">', 3)
If @error = 0 Then
$s = 'http://www.uname.cn' & $Link[0]
Else
IniWrite("e1cw.ini", $chars, @YEAR & "-" & @MON & "-" & @MDAY & "-" & @HOUR & "-" & @MIN & " 步骤5-这将是个错误回馈,而且也会因此停止程序的运行", $s)
EndIf
$oIE2 = _XmlHttp($s)
$sR = StringRegExp($oIE2, '#FFFFFF">(.*?)( )?</td>', 3)
If @error = 0 Then
IniWrite("e1.ini", "Section3", @YEAR & "-" & @MON & "-" & @MDAY & "-" & @HOUR & "-" & @MIN & "-" & @SEC & "_" & $chars, $sR[0] & "," & $sR[2] & "," & $sR[3] & "," & $sR[4] & "," & $sR[6] & "," & $sR[7] & "," & $sR[8] & "," & $sR[9])
ElseIf @error <> 0 Then
IniWrite("e1cw.ini", $chars, @YEAR & "-" & @MON & "-" & @MDAY & "-" & @HOUR & "-" & @MIN & " 步骤7", $chars & "," & $sR[0] & "," & $sR[2] & "," & $sR[3] & "," & $sR[4] & "," & $sR[6] & "," & $sR[7] & "," & $sR[8] & "," & $sR[9])
EndIf
$sl = $sl + 1
ToolTip($sR[0] & "," & $sR[2] & "," & $sR[3] & "," & $sR[4] & "," & $sR[6] & "," & $sR[7] & "," & $sR[8] & "," & $sR[9], 50, 50, @YEAR & "-" & @MON & "-" & @MDAY & "-" & @HOUR & "-" & @MIN & "-" & @SEC & @CR & "已经完成了第" & $sl & "个字上一个是" & $chars, 0, 4)
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
|
|