本帖最后由 cxlater 于 2014-4-3 09:57 编辑
Func query()
$searchkey = GUICtrlRead($Input2)
If $searchkey = "" Then Return
Do
_IELoadWait($oIE)
$htmlcode = _IEDocReadHTML($oIE)
If StringInStr($htmlcode , $searchkey) Then
$ask = MsgBox(4,0,"当前页面发现特征码,是否继续?")
If $ask <> 6 Then Return
EndIf
If Not _IELinkClickByText($oIE , "下一页") Then
MsgBox(0,0,"已经到最后一页!")
Return
EndIf
Until 0
EndFunc
本段代码实现在_IECreateEmbedded创建的浏览器对象里打开某网页,判断页面代码是否包含特定关键字,并不断点击下一页进行查找。
实际应用中,随着查找页数的增多 进程所占用的内存高的吓人 70页过后占了近两G
请问各位大神什么地方出了问题
附可运行测试代码(无退出功能 需Break it):
#NoTrayIcon
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
$Form1 = GUICreate("Form1", 1488, 576, 192, 114)
$Button2 = GUICtrlCreateButton("从当前页面开始匹配", 936, 16, 131, 25)
$oIE = _IECreateEmbedded()
$objie = GUICtrlCreateObj($oIE, 8, 48, 1470, 521)
GUISetState(@SW_SHOW)
_IENavigate($oIE ,"http://s.taobao.com/search?initiative_id=staobaoz_20140402&js=1&q=%D0%C2%BF%EE+%C5%AE%D7%B0&stats_click=search_radio_all%3A1")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
que()
EndSwitch
WEnd
Func que()
$searchkey = "Test"
Do
_IELoadWait($oIE)
$htmlcode = _IEDocReadHTML($oIE)
If StringInStr($htmlcode , $searchkey) Then
$ask = MsgBox(4,0,"当前页面发现特征码,是否继续?")
If $ask <> 6 Then Return
EndIf
If Not _IELinkClickByText($oIE , "下一页") Then
MsgBox(0,0,"已经到最后一页!")
Return
EndIf
Until 0
EndFunc
|