AU3如何操作不典型的网页表单?[已解决]
本帖最后由 cashiba 于 2016-10-16 19:53 编辑如上图。<form method="POST" class="quc-form">
<p class="quc-field quc-field-account quc-input-long"><label for="quc_account_384028623" class="quc-label">帐 号</label><span class="quc-input-bg quc-input-bg-focus">
<input id="quc_account_384028623" class="quc-input quc-input-account" name="account" placeholder="手机号/用户名/邮箱" autocomplete="off" type="text" /></span></p>
<div class="quc-email-hint-wrapper">
<div style="width: 228px; display: none;" class="quc-email-hint">
<a style="display: block;" tabindex="-1" href="#">@sina.com</a>
<a style="display: block;" tabindex="-1" href="#">@163.com</a>
</div>
</div>
<p></p>
<p class="quc-field quc-field-password quc-input-long"><label for="quc_password_384028624" class="quc-label">密 码</label><span class="quc-input-bg">
<input id="quc_password_384028624" class="quc-input quc-input-password" name="password" maxlength="20" placeholder="请输入您的密码" type="password" /></span></p>
<p class="quc-field quc-field-captcha quc-input-short clearfix"><label for="quc_phrase_384028625" class="quc-label">验证码</label><span class="quc-input-bg"><input id="quc_phrase_384028625" class="quc-input quc-input-captcha" name="phrase" maxlength="7" autocomplete="off" placeholder="请输入验证码" type="text" /></span><img class="quc-captcha-img quc-captcha-change" alt="验证码" title="点击更换" tabindex="99" /> <a class="quc-link quc-captcha-change-link quc-captcha-change" href="#">换一张</a></p>
<p class="quc-field quc-field-keep-alive"><label><input class="quc-checkbox quc-checkbox-keep-alive" name="iskeepalive" type="checkbox" />下次自动登录</label></p>
<p class="quc-field quc-field-submit">
<input value="登录" class="quc-submit quc-button quc-button-sign-in" type="submit" /> </p>
<p style="display: none;" class="quc-field quc-field-third-part"><span>其他帐号登录:</span><span class="quc-third-part"></span></p>
</form>
最近学学AU3操作网页DOM。但是不少函数看不懂,也不会用.....{:face (239):}
现在练习,想弄个自动登录http://yunpan.360.cn/,但是发现:
1、表单<form>无Name,无ID
2、登录按钮无Name,无图片
如何套用下方代码呢?#include <IE.au3>
Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetObjByName($oIE, "gbqf")
Local $oQuery = _IEFormElementGetObjByName($oForm, "q")
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm) 验证码你怎么弄 这是子页吧?
zhao_ming 发表于 2016-10-7 14:05 http://www.autoitx.com/images/common/back.gif
是的,网页源代码中下面这段提示了表单位置:<div class="login-panel">
<h1>欢迎使用360云盘!</h1>
<div id="login"></div>
<div class="change"></div>
</div>
本帖最后由 cxlater 于 2016-10-7 22:07 编辑
#AccAu3Wrapper_UseX64=n ;是否编译为64位程序(y/n)
#NoTrayIcon
#include<IE.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 859, 548, 192, 114)
$oie = _IECreateEmbedded()
GUICtrlCreateObj($oIE, 0, 0, 857, 545)
GUISetState(@SW_SHOW)
_IENavigate($oie ,"https://yunpan.360.cn/")
$user = _IEGetObjByName($oie ,"account")
$pass = _IEGetObjByName($oie ,"password")
$loginbtn = _IETagNameGetCollection($oie ,"input" ,4)
$user.value = "testname"
$pass.value = "testpass"
$loginbtn.click
Do
Sleep(50)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
万变不离其宗,au3的用户自定义函数仅提供了一些常用的功能,想实现更复杂的功能还要对前端知识多了解一点。
cxlater 发表于 2016-10-7 22:04 http://www.autoitx.com/images/common/back.gif
$loginbtn = _IETagNameGetCollection($oie ,"input" ,4)
通过标签索引定位,以前对这个很不熟悉,看到这个例子总算明白了,感谢,感谢!{:face (332):} 万变不离其宗,au3的用户自定义函数仅提供了一些常用的功能,想实现更复杂的功能还要对前端知识多了解一点。 ...
nmgwddj 发表于 2016-10-9 18:13 http://www.autoitx.com/images/common/back.gif
要学的东东太多了,没人指点的话,一个人琢磨,常常是不得要领,甚至钻进牛角尖,....所以希望论坛人气旺些,再旺些,学习得才快....{:face (84):}
页:
[1]