ImgGetCollection怎么遍历模拟点击
本帖最后由 jhkdqaa 于 2009-5-13 11:59 编辑关于一个php的网页。新手上路,大侠们帮忙看看:face (37):
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
$Form1 = GUICreate("每日自动刷新",700,480)
$Group1 = GUICtrlCreateGroup("", 8, 8, 684, 400)
$oIE = _IECreateEmbedded ()
$GUIActiveX = GUICtrlCreateObj($oIE,16, 24, 668, 374)
$Edit = GUICtrlCreateEdit("", 8, 420, 500,50)
GUICtrlSetBkColor(-1, 0xFFFFE1)
GUICtrlSetColor(-1, 0x008000)
$Button1 = GUICtrlCreateButton("首 页", 516, 420, 84, 50)
$Button2 = GUICtrlCreateButton("刷 新", 608, 420, 84, 50)
GUISetState(@SW_SHOW)
$oIE.navigate("http://www.asianproducts.com/")
GUICtrlSetData($Edit,"请自行设置用户名和密码登陆")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$oIE.navigate("http://www.asianproducts.com/")
Case $Button2
$UserName = _IEGetObjById ($oIE, "client_login_name")
If IsObj($UserName) Then $UserName.value = "留着以后读数据库"
$PassWord = _IEGetObjById ($oIE, "client_login_password")
If IsObj($PassWord) Then $PassWord.value = "留着以后读数据库"
$submit = _IEGetObjById ($oIE, "button")
If IsObj($submit) Then $submit.click
sleep(2000)
GUICtrlSetData($Edit,"请稍后,正在操作...")
_IELoadWait($oIE)
GUICtrlSetData($Edit,"已登陆")
$oIE.navigate("http://www.asianproducts.com/member.php")
_IELoadWait($oIE)
_IELinkClickByText($oIE,"My online products")
_IELoadWait($oIE)
_IEImgClick($oIE,"http://www.asianproducts.com/clientAdmin/images/big_icon3_smaller.gif","src")
_IELoadWait($oIE)
_IEImgClick($oIE,"http://www.asianproducts.com/clientAdmin/images/save_data1.gif","src")
EndSwitch
WEnd
问题就是这个网页有N个长的一样的图片链接,怎样通过_IEImgGetCollection逐个点击?只需要针对第一个图片链接就可以了。坐等高手帮忙:face (37): 是不是
$oImgs = _IEImgGetCollection ($oIE)
For $oImg In $oImgs
If StringInStr($oImg.src,"http://www.asianproducts.com/clientAdmin/images/big_icon3_smaller.gif") = 0 Then
then后面的click怎么写?这样就可以遍历么? 是不是
$oImgs = _IEImgGetCollection ($oIE)
For $oImg In $oImgs
If StringInStr($oImg.src,"http://www.asianproducts.com/clientAdmin/images/big_icon3_smaller.gif") = 0 Then
then后面的click怎么写?这样就可以遍历么? 你干嘛复制我的话。。。。。这是灌水新方法吗:face (9): 本帖最后由 jhkdqaa 于 2009-5-13 11:59 编辑
自己解决了一部分,发出来新手交流下。
$oimgs = _IEImgGetCollection($oIE)
$iNumimg = @extended
dim $imglist[$iNumimg]
dim $i = 0
for $i = 0 to @extended
$imglist[$i] = _IEImgGetCollection($oIE, $i)
oimgclick = $imglist[$i]
if $oimgclick.src = "http://www.asianproducts.com/clientAdmin/images/big_icon3_smaller.gif" then
_IEAction($oimgclick, "click")
_IELoadWait($oIE)
_IEImgClick($oIE, "http://www.asianproducts.com/clientAdmin/images/save_data1.gif", "src")
_IELoadWait($oIE)
_IELinkClickByText($oIE, "My online products")
_IELoadWait($oIE)
EndIf
next
已经可以实现遍历,但是在遍历完成以后,i=10<@extended,会继续循环,错误退出。但是把@extended改成数字就会出错。高手教导下怎么停止循环?是 if $i = 9 then end loop 么?
大概是这个意思,教程里没有提到怎么终止循环,帮助里搜索loop为空。坐等高手上文教导:face (23): 自己搞定:for $i = 0 to @extended
改成 for $i = 0 to (@extended -1)
页:
[1]