|
本帖最后由 jhkdqaa 于 2009-5-20 17:25 编辑
初级代码:
Func asianproduct()
$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
_IELoadWait($oIE)
GUICtrlSetData($Edit, "请稍后,正在操作...")
_IELoadWait($oIE)
GUICtrlSetData($Edit, "已登陆")
$oIE.navigate("http://www.asianproducts.com/member.php")
_IELoadWait($oIE)
_IELinkClickByText($oIE, "My online products")
GUICtrlSetData($Edit, "请稍后,正在更新...")
_IELoadWait($oIE)
$oimgs = _IEImgGetCollection($oIE)
$iNumimg = @extended
dim $imglist[$iNumimg]
dim $i = 0
for $i = 0 to(@extended - 1)
$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
EndFunc
运行正常。
给他加载数据库怎么怎么以后就冗余了,老是在遍历,还重复的。
冗余的代码:
Func asianproduct()
$conn = ObjCreate("ADODB.Connection")
$rs = ObjCreate("ADODB.Recordset")
$conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $dbname & ";Jet Oledb:Database ")
$rs.ActiveConnection = $conn
$rs.Open("Select * From allcustomer where website = 'asianproducts'")
while Not $rs.eof And Not $rs.bof
if @error = 1 Then ExitLoop
$p = $rs.Fields(3).value
$UserName = _IEGetObjById($oIE, "client_login_name")
If IsObj($UserName) Then $UserName.value = $rs.Fields(1).value
$PassWord = _IEGetObjById($oIE, "client_login_password")
If IsObj($PassWord) Then $PassWord.value = $rs.Fields(2).value
$submit = _IEGetObjById($oIE, "button")
If IsObj($submit) Then $submit.click
_IELoadWait($oIE)
GUICtrlSetData($Edit, "请稍后,正在操作...")
_IELoadWait($oIE)
GUICtrlSetData($Edit, "已登陆")
$oIE.navigate("http://www.asianproducts.com/member.php")
_IELoadWait($oIE)
_IELinkClickByText($oIE, "My online products")
_IELoadWait($oIE)
$URl = _IEPropertyGet($oIE, "locationurl")
GUICtrlSetData($Edit, "请稍后,正在更新...")
for $j = 1 to $p
$Url = $URl
if $j > 1 then
$Url = StringReplace($Url, "showonline", "showonline&page=" & $j)
EndIf
_IENavigate($oIE, $Url)
_IELoadWait($oIE)
$oimgs = _IEImgGetCollection($oIE)
$iNumimg = @extended
dim $imglist[$iNumimg]
$i = 0
for $i = 0 to(@extended - 1)
$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)
_IENavigate($oIE, $Url)
_IELoadWait($oIE)
EndIf
next
next
_IELinkClickByText($oIE, "Sign Out")
_IELoadWait($oIE)
$rs.movenext
WEnd
$rs.close
$conn.Close
EndFunc
拜托高手教导下 |
|