我做了一个自动填表但是经常自动退出
我有次试了一下,这个和我的速度有关系?
如果这样第二次就报错误了#include <IE.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", 0, 0)
$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
MsgBox(0,"","错误")
EndIf
IniWrite("e1.ini", "Section3",$chars, $s)
$sl = $sl + 1
ToolTip("网址: " & $s, 50, 50, "已经完成了第" & $sl & "个字上一个是" & $chars, 0, 4)
_IEQuit($oIE)
WEnd
但是如果这样的话就能长久25次多吧,但是如何才能稳定呢?#include <IE.au3>
$file = FileOpen("zi.txt", 0)
If $file = -1 Then
MsgBox(0, "错误", "在脚本目录下建立zi.txt的文本文件在写几个汉字")
Exit
EndIf
$sl = 0
While 1
$chars = FileRead($file, 2)
Sleep(1000)
$oIE = _IECreate("http://www.uname.cn/dic/zidian.asp", 0, 0)
Sleep(1000)
$a = _IEGetObjByName($oIE, "gb")
Sleep(1000)
_IEFormElementSetValue($a, $chars)
Sleep(1000)
$oSubmit = _IEGetObjByName($oIE, "gb")
Sleep(1000)
$b = _IEGetObjByName($oIE, "Submit")
Sleep(1000)
_IEAction($b, "click")
Sleep(1000)
_IELoadWait($oIE)
$sHTML = _IEBodyReadHTML($oIE)
$Link = StringRegExp($sHTML, 'href="(/html/dic/[^"]+)">', 3)
If @error = 0 Then
$s = 'http://www.uname.cn' & $Link[0]
Else
MsgBox(0,"","错误")
EndIf
IniWrite("e1.ini", "Section3",$chars, $s)
$sl = $sl + 1
ToolTip("网址: " & $s, 50, 50, "已经完成了第" & $sl & "个字上一个是" & $chars, 0, 4)
_IEQuit($oIE)
WEnd
|