作者: qqmmcc
時間: 2011-4-30 20:52
標(biāo)題: web自動登錄方法匯總(轉(zhuǎn)自老大指導(dǎo))
使用ele.form.submit提交的方法
import win.ui;
import web.form;
/*DSG{{*/
var winform = win.form(parent=...; min=1;bottom=249;scroll=1;right=349;text="AAuto Form";max=1 )
winform.add( )
/*}}*/
//創(chuàng)建web窗體
var wb = web.form( winform );
//打開目標(biāo)網(wǎng)站
wb.go("http://secure.verycd.com/3rdServices/50hero")
winform.show(true)
wb.wait("");
//登錄
wb.getEle("username").value="登錄用戶名"
ele = wb.getEle("password")
ele.value="999999"
ele.form.action = 'http://secure.verycd.com/signin?f=out'
ele.form.submit()
//進入消息循環(huán)
win.loopMessage();
return wb,winform;
使用wb.doScript執(zhí)行js腳本提交的方法
import win.ui;
import web.form;
/*DSG{{*/
var winform = win.form(parent=...; min=1;bottom=249;scroll=1;right=349;text="AAuto Form";max=1 )
winform.add( )
/*}}*/
//創(chuàng)建web窗體
var wb = web.form( winform );
//打開目標(biāo)網(wǎng)站
wb.go("http://secure.verycd.com/3rdServices/50hero")
winform.show(true)
wb.wait("");
//登錄
wb.getEle("username").value="登錄用戶名"
wb.getEle("password").value="999999"
wb.doScript("FormSubmit()")
//進入消息循環(huán)
win.loopMessage();
return wb,winform;
使用wb.Script.函數(shù)(至少一個參數(shù)) 執(zhí)行腳本提交
import win.ui;
import web.form;
/*DSG{{*/
var winform = win.form(parent=...; min=1;bottom=249;scroll=1;right=349;text="AAuto Form";max=1 )
winform.add( )
/*}}*/
//創(chuàng)建web窗體
var wb = web.form( winform );
//打開目標(biāo)網(wǎng)站
wb.go("http://secure.verycd.com/3rdServices/50hero")
winform.show(true)
wb.wait("");
//登錄
wb.getEle("username").value="登錄用戶名"
wb.getEle("password").value="999999"
/*
執(zhí)行js函數(shù)必須要有實參,不需要參數(shù)的函數(shù)可以隨便寫一個也可以,
這種直接調(diào)用js函數(shù)的方法能取到j(luò)s函數(shù)的返回值,而wb.doScript()是不行的。
如果不寫參數(shù),返回的是函數(shù)對象本身,而不是調(diào)用函數(shù)。
*/
wb.script.FormSubmit(0)
//進入消息循環(huán)
win.loopMessage();
return wb,winform
用wb.eachAll()查找節(jié)點,并使用ele.click()模擬點擊提交.
import win.ui;
import web.form;
/*DSG{{*/
var winform = win.form(parent=...; min=1;bottom=249;scroll=1;right=349;text="AAuto Form";max=1 )
winform.add( )
/*}}*/
//創(chuàng)建web窗體
var wb = web.form( winform );
//打開目標(biāo)網(wǎng)站
wb.go("http://secure.verycd.com/3rdServices/50hero")
winform.show(true)
wb.wait("");
//登錄
wb.getEle("username").value="登錄用戶名"
wb.getEle("password").value="999999"
//遍歷所有input節(jié)點
for( i,ele in wb.eachAll("input") ){
if( ele.src == "http://game.verycd.com/hero/wp-content/themes/hero_v1/images/dl.gif" )
ele.click();
}
//進入消息循環(huán)
win.loopMessage();
return wb,winform;
用wb.queryEles()查找節(jié)點執(zhí)行click()方法提交
該函數(shù)用法參考帖子:
http://www.aau.cn/thread-2490-1-1.html
import win.ui;
/*DSG{{*/
var winform = win.form(parent=...; min=1;bottom=249;scroll=1;right=349;text="AAuto Form";max=1 )
winform.add( )
/*}}*/
import web.form;
//創(chuàng)建web窗體
var wb = web.form( winform );
//打開目標(biāo)網(wǎng)站
wb.go("http://secure.verycd.com/3rdServices/50hero")
winform.show(true)
wb.wait("");
//登錄
wb.getEle("username").value="登錄用戶名"
wb.getEle("password").value="999999"
wb.queryEles (
src = "dl.gif";
tagName = "input"
).click()
//進入消息循環(huán)
win.loopMessage();
return winform,wb;
使用wb窗體自動post提交
import win.ui;
import web.form;
/*DSG{{*/
var winform = win.form(parent=...; min=1;bottom=249;scroll=1;right=349;text="AAuto Form";max=1 )
winform.add( )
/*}}*/
//創(chuàng)建web窗體
var wb = web.form( winform );
//構(gòu)建上傳數(shù)據(jù)
postData = string.fromto(
"ru=http%3A%2F%2Fsecure.verycd.com%2F3rdServices%2F50hero&login_submit=%E7%99%BB%E5%BD%95&username=登錄用戶名&password=999999&x=33&y=15&_REFERER="
,0
,65001
)
//自動提交
wb.post("http://secure.verycd.com/signin?f=out"
,postData )
//顯示窗口
winform.show(true)
//進入消息循環(huán)
win.loopMessage();
return wb,winform;
不使用web窗體自動post提交
import process;
import inet.whttp
whttp = inet.whttp();
//構(gòu)建上傳數(shù)據(jù)
postData = string.fromto(
"ru=http%3A%2F%2Fsecure.verycd.com%2F3rdServices%2F50hero&login_submit=%E7%99%BB%E5%BD%95&username=登錄用戶名&password=999999&x=33&y=15&_REFERER="
,0
,65001
)
str,errmsg = whttp.post("http://secure.verycd.com/signin?f=out" ,postData );
whttp.close();//釋放資源
if(str){//如果提交成功則保存到指定文件
string.save("/post.html",str )
process.execute( "/post.html" )
}
else{//否則輸出錯誤信息
win.msgbox(errmsg)
}
作者: carl
時間: 2011-4-30 21:18
這種形式的總結(jié)要大力支持
作者: 低調(diào)點
時間: 2011-5-1 09:19
wb.document.getElementById("J_StaticForm").submit()
和ele.form.submit差不多.
作者: o00viw
時間: 2011-5-1 13:27
這個值得收藏,繼續(xù)深入學(xué)習(xí)下。
作者: jsniu
時間: 2011-5-1 13:36
好帖!收藏學(xué)習(xí),必須的。
作者: sj798
時間: 2011-5-2 06:06
收藏了,以后有用的著的時候
作者: greenbud
時間: 2011-5-4 10:36
收藏ing
作者: freemanol
時間: 2011-5-5 08:56
值得收藏,深入學(xué)習(xí)
作者: set555
時間: 2011-5-5 13:08
先收藏了 謝謝!
作者: cissy
時間: 2011-5-16 17:34
呵呵 好的東西就是要收藏的
作者: 太子
時間: 2011-5-16 17:47
收藏
作者: fantasynew
時間: 2011-5-24 19:54
感謝Q版的整理,很有用
作者: zhanyong
時間: 2011-5-26 09:44
謝謝版主的支持。。。
作者: 劉旭錢
時間: 2011-7-14 10:53
收藏,繼續(xù)深入學(xué)習(xí)
作者: glod123
時間: 2011-7-18 09:05
這個實用,強大??!
作者: 海飄飄
時間: 2011-7-22 10:37
有一特例登錄方式,調(diào)用頁面JS,改寫成AAu語句來實現(xiàn)
網(wǎng)頁JS代碼如下
- <script>
- function jump(regtype){
- document.form1.regtype.value=regtype;
- document.form1.submit();
- }
- </script>
復(fù)制代碼網(wǎng)頁源文件
- <form name="form1" action="/NoteAction.do" method="post">
- <input type="hidden" name="method" value="addSign"/>
- <input type="hidden" name="regtype" value=""/>
- <input type="hidden" id="guid" name="guid" size="0"/>
- <input type="hidden" id="adid" name="adid" size="0"/>
- <input type="hidden" id="hdid" name="hdid" size="0"/>
- <input type="hidden" id="refer" name="refer" size="0"/>
- <a href="#" onclick="jump('normalReg');return false;" class="btn_reg">免費注冊</a>
復(fù)制代碼使用AAu登錄方式
- ele=wb.getEle("regtype")
- if(ele){
- ele.setAttribute("value","normalReg")//設(shè)置類型
- }
- ele.form.submit()//自動提交表單