本帖最后由 lsb968 于 2013-8-31 16:08 编辑
表单提交汇总……
;第一种
#include <IE.au3>
$oIE = _IECreate ("http://mail.163.com",0,1,1,0)
_IEPropertySet ($oIE, "width", 800)
_IEPropertySet ($oIE, "height", 600)
$oForm = _IEFormGetObjByName ($oIE, "login163")
$oQuery = _IEFormElementGetObjByName ($oForm, "username")
_IEFormElementSetValue ($oQuery,''XXXXXX")
$oQuery = _IEFormElementGetObjByName ($oForm, "password")
_IEFormElementSetValue ($oQuery, ''XXXXX')
$oIE.document.getElementsByTagName('button').item(0).click
_IEAction ($oIE, "visible")
;第二种
#include <IE.au3>
$oIE = _IECreate ("http://t.sina.com.cn")
$oUser = _IEGetObjById ($oIE, "username")
$oPass = _IEGetObjById ($oIE, "password")
_IEFormElementSetValue ($oUser, "XXXXX")
_IEFormElementSetValue ($oPass, "XXXXX")
$oLogin = _IEGetObjById ($oIE, "login_submit_btn")
$oLogin.click()
;第三种
#include <IE.au3>
$oIE = _IECreate("http://mail.163.com", 0, 1, 1, 0)
_IELoadWait($oIE)
_IEPropertySet($oIE, "width", 800)
_IEPropertySet($oIE, "height", 600)
$oInputs = _IETagNameGetCollection($oIE, "INPUT")
For $oInput In $oInputs
If $oInput.name = "username" Then
$oInput.value = 'XXXXXXXXX'
EndIf
Next
For $oInput In $oInputs
If $oInput.name = "password" Then
$oInput.value = 'XXXXXX'
EndIf
Next
$oIE.document.getElementsByTagName('button').item(0).click
For $oInput In $oInputs
If $oInput.type = "submit" Then
_IEAction($oInput, "click")
EndIf
Next
;第四种
#include <IE.au3>
$oIE = _IECreate("https://passport.csdn.net/account/login", 0, 1, 1, 0)
$oFrame = _IEGetObjById($oIE,"logfrm")
$oIE = $oFrame.contentWindow
$Ele = _IEGetObjById($oIE,"u")
_IEFormElementSetValue($Ele,"xxx")
$Ele2 = _IEGetObjById($oIE,"p")
_IEFormElementSetValue($Ele2,"xxxx")
$Ele3 = _IETagNameGetCollection($oIE,"SPAN",0)
_IEAction($Ele3, "click")
;contentWindow 属性是指指定的 frame 或者 iframe 所在的 window 对象
;在 IE 中 iframe 或者 frame 的 contentWindow 属性可以省略,但在 Firefox 中如果要对 iframe 对象进行编辑则必须指定contentWindow属性。
|