关于post登陆论坛
本帖最后由 xyhqqaa 于 2013-3-12 11:39 编辑新手,正在学POST。$oIE = _IECreate("http://www.zt2cn.com/logging.php?action=login", 0, 1, 1, 1)
_IELoadWait($oIE)
$UserName = _IEGetObjById($oIE, "username")
If IsObj($UserName) Then $UserName.value = "oneboy"
$PassWord = _IEGetObjById($oIE, "password3")
If IsObj($PassWord) Then $PassWord.value = "123456789"
$oInputs = _IETagNameGetCollection($oIE, "input")
For $oInput In $oInputs
$buttonclick = _IEGetObjByName($oIE, "loginsubmit")
_IEAction($buttonclick, 'click')
ExitLoop
If @error Then Exit
Next
之前是使用这种方式登陆成功,签到没弄成功,只能手动签到。。。
现在想学习是否能用post登陆签到。但是测试结果很悲惨
测试源码如下,就是不知道哪错了,对比了下前辈们登陆论坛的例子,发现zt2cn跟acn的论坛差不多的样子好像。就拿前辈的例子来借鉴,却发现不能用,囧
Local $user = 'oneboy'
Local $pass = '123456789'
$xmlHttpReq = ObjCreate("MSXML2.XMLHTTP.3.0")
$xmlHttpReq.open("GET", 'http://www.zt2cn.com/space-uid-85916.html', false)
$xmlHttpReq.send()
$Content = BinaryToString($xmlHttpReq.responseBody,1)
$FormHash = StringRegExp($Content,'name="formhash" value="(.*?)\"',3)
If @error = 0 Then
$xmlHttpReq.open("POST",'http://www.zt2cn.com/space-uid-85916.html',false)
$xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded')
$xmlHttpReq.send('formhash='&$FormHash&'&loginfield=username&username='&$user&'&password='&$pass&'&questionid=0&answer=&cookietime=2592000&loginsubmit=%B5%C7%C2%BC')
$Content = BinaryToString($xmlHttpReq.responseBody,1)
$xmlHttpReq.abort()
If StringRegExp($Content,'<p>欢迎您回来,'&$user&'。现在将转入登录前页面。</p>',0) Then MsgBox(0,"","登录成功!")
EndIf
新手求解,正则不懂..有比较适合新手学习POST的。。。求介绍 本帖最后由 星雨朝霞 于 2013-3-12 13:46 编辑
;论坛密码转换MD5
$sc = ObjCreate("ScriptControl")
$sc.Language="Javascript"
$username='****'
$password='******'
$Islogin=False
$formhash_Conetent=XMLHTTP('http://www.zt2cn.com/logging.php?action=login&infloat=yes&handlekey=login&inajax=1&ajaxtarget=fwin_content_login')
If Not @error Then
If StringInStr($formhash_Conetent,'欢迎您回来')=0 Then
$formhash=StringRegExp($formhash_Conetent,"formhash=(.*?)'",3)
If Not @error Then
$sc.AddCode(XMLHTTP('http://www.zt2cn.com/forumdata/cache/md5.js?iiA'))
$password=$sc.Eval('hex_md5("'&$password&'")')
$Post_data='formhash='&$formhash&'&referer=index.php&loginfield=username&username='&$username&'&password='&$password&'&questionid=0&answer='
$login_Conetent=XMLHTTP('http://www.zt2cn.com/logging.php?action=login&loginsubmit=yes&floatlogin=yes&inajax=1',1,'POST',$Post_data)
If StringInStr($login_Conetent,'欢迎您回来') Then
$Islogin=True
Else
$Islogin=False
EndIf
EndIf
Else
$Islogin=True
EndIf
If $Islogin=True Then
$postbox_Conetent=XMLHTTP('http://www.zt2cn.com/plugin.php?identifier=dps_sign&module=sign&operation=qiandao&infloat=1&inajax=1',1,'POST','qdxq=fd&qdmode=3&todaysay=&fastreply=1')
If Not @error Then
$postbox_Text=StringRegExp($postbox_Conetent,'postbox">([\W\w]*?)<',3)
If Not @error Then
TrayTip('征途兔之窝>>每日签到',$postbox_Text,10)
Sleep(10000)
EndIf
EndIf
EndIf
EndIf
Func XMLHTTP($webURL,$webresponse=1,$webMode='GET',$webdate='')
Global $WinHttp
$WinHttp = ObjCreate("Microsoft.XMLHTTP")
$SinkObject=objevent('AutoIt.Error',"MyErrFunc")
$WinHttp.Open ($webMode, $webURL,False)
$WinHttp.setRequestHeader ("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0 QQDownload/1.7")
If $webMode='POST' Then
$WinHttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded")
$WinHttp.Send ($webdate)
Elseif $webMode='GET' Then
$WinHttp.setRequestHeader ("Content-Type", "text/xml")
$WinHttp.Send ()
EndIf
If $webresponse=1 Then
Return $WinHttp.responseText
ElseIf $webresponse=0 Then
Return BinaryToString($WinHttp.responseBody)
EndIf
EndFunc
Func MyErrFunc()
;出错处理函数
SetError(1)
EndFunc 回复 2# 星雨朝霞
正在慢慢消化。。。。谢谢草哥。。。话说好多理解不懂- -!! POST操作,学习。。。。。。。。。
页:
[1]