找回密码
 加入
搜索
查看: 2339|回复: 0

[IE类操作] 关于用POST进行论坛登录的问题!

[复制链接]
发表于 2015-5-14 23:25:24 | 显示全部楼层 |阅读模式
希望专家看看针对我的问题看有没有好的解决方案?

目前问题:
1、在运行过程中,POST和获取信息太慢(可以用龟速形容),专家帮忙看下代码哪里有问题?
2、在账号和密码都正确的情况下,时而判断失败,时而判断成功,是否跟问题1有直接关系?

备注:代码中以有论坛的账号和密码!
Global $UserName, $password
Global $LoginPage, $PostPage, $CheckPage
Global $xmlhttp, $bodytext
Global $PostData, $Formhash, $cookietime
 
$UserName = 'abcd1234'
$password = 'abcd1234'
 
$CheckPage = "http://bbs.ieyos.com/"
$LoginPage = "http://bbs.ieyos.com/member.php?mod=register"
$PostPage = 'http://bbs.ieyos.com/member.php?mod=logging&action=login&loginsubmit=yes&loginhash=LAeAE&inajax=1'
 
$xmlhttp = ObjCreate("MSXML2.XMLHTTP.3.0")
;===========以下是检测帐号是否登录,如果登陆就先退出==============
$xmlhttp.open("GET", $CheckPage, False)
$xmlhttp.send()
$bodytext = BinaryToString($xmlhttp.responseBody, 1)
If StringInStr($bodytext, '个人中心') Then
        $Formhash = StringRegExp($bodytext, 'formhash=(.*?)"', 3)
        $xmlhttp.open("GET", 'http://bbs.ieyos.com/home.php?mod=space&do=pm', False)
        $xmlhttp.send()
EndIf
;=================以下是获取postdata===============================
$xmlhttp.open("GET", $LoginPage, False)
$xmlhttp.send()
$bodytext = BinaryToString($xmlhttp.responseBody, 1)
$cookietime = StringRegExp($bodytext, 'name="cookietime".*?value="(.*?)"', 3)
$Formhash = StringRegExp($bodytext, 'name="formhash" value="(.*?)"', 3)
If Not @error Then $PostData = 'formhash=' & $Formhash[0] & '&referer=http%3A%2F%2Fbbs.ieyos.com%2Fmember.php%3Fmod%3Dregister' & '&loginfield=username&username=' & $UserName & '&password=' & $password & '&questionid=0&answer=' & $cookietime[0]
;~ If Not @error Then $PostData = 'formhash=' & $Formhash[0] & '&loginfield=username&username=' & $UserName & '&password=' & $password & '&questionid=0&answer=&cookietime=' & $cookietime[0]
 
;===========以下是发送post数据,并检测登录是否成功================
 
$xmlhttp.open("POST", $PostPage, False)
$xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
;~ $xmlhttp.setRequestHeader('referer', 'http://autoitx.com/')
$xmlhttp.send($PostData)
$bodytext = BinaryToString($xmlhttp.responseBody, 1)
ConsoleWrite($bodytext)
If StringInStr($bodytext, '欢迎您回来') Then
        MsgBox(0, "", "登录成功!")
Else
        MsgBox(0, "", "登录失败!")
EndIf
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-27 08:34 , Processed in 0.075742 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表