tryhi 发表于 2012-9-25 18:32:39

请教个POST问题(百度登陆)

这两段代码均登陆不上去,不知原因


#include <WinHttp_GetRespond.au3>
#Include <Array.au3>
$Name = 'plfeyp50205'
$Pass = 'hqacaf19005'
$open = _WinHttpOpen()
$http = _WinHTTP_GetRespond($open,'https://passport.baidu.com/v2/?login&fr=old',5,5000,'callback=parent.bdPass.api.login._postCallback&'& _
'charset=utf-8&'& _
'codestring=&'& _
'index=0&'& _
'isPhone=false&'& _
'loginType=1&'& _
'password='&$Pass&'&'& _
'ppui_logintime=25422&'& _
'safeflg=0&'& _
'staticpage=https://passport.baidu.com/v2Jump.html&'& _
'token=4f2a39b477b52b8929ced1e57761d35a&'& _
'tpl=pp&'& _
'u=&'& _
'username='&$Name&'&'& _
'verifycode=')
_ArrayDisplay($http)


$Name = 'plfeyp50205'
$Pass = 'hqacaf19005'
$oHTTP = ObjCreate("Msxml2.xmlhttp")
$oHTTP.Open("Post", "https://passport.baidu.com/v2/?login&fr=old", False)
$oHTTP.setRequestHeader("Cache-Control", "no-cache")
$oHTTP.setRequestHeader("Content-Type", "text/html;charset=gbk")
$oHTTP.setRequestHeader("Referer", "https://passport.baidu.com/v2/?login&fr=old")
$oHTTP.Send('callback=parent.bdPass.api.login._postCallback&'& _
'charset=utf-8&'& _
'codestring=&'& _
'index=0&'& _
'isPhone=false&'& _
'loginType=1&'& _
'password='&$Pass&'&'& _
'ppui_logintime=25422&'& _
'safeflg=0&'& _
'staticpage=https://passport.baidu.com/v2Jump.html&'& _
'token=4f2a39b477b52b8929ced1e57761d35a&'& _
'tpl=pp&'& _
'u=&'& _
'username='&$Name&'&'& _
'verifycode=')
$Log = BinaryToString($oHTTP.responseBody)
MsgBox(0,0,$Log)


suiyefeng 发表于 2012-9-25 18:32:40

本帖最后由 suiyefeng 于 2012-9-25 22:07 编辑

#include <WinHttp_GetRespond.au3>


$Name = 'plfeyp50205'
$Pass = 'hqacaf19005'
login($Name, $Pass)

Func login($Name, $Pass)
        $MyOpen = _WinHttpOpen()
        $rContext = _WinHTTP_GetRespond($MyOpen ,'http://www.baidu.com/cache/user/html/login-1.2.html',4+2,5000)
        If @error Then
                Return -1
        EndIf
       
        $rContext = _WinHTTP_GetRespond($MyOpen ,'https://passport.baidu.com/v2/api/?getapi&class=login&tpl=mn&tangram=true',4+2,5000)
        If @error Then
                Return -1
        EndIf
        MsgBox(0,0,$rContext)

        $token = StringRegExp($rContext, "login_token='(.*?)';", 3)
        If IsArray($token) Then
                $token = $token
        Else
                Return -1
               
        EndIf

        MsgBox(0,0,$token)
               
       
        $List = "https://passport.baidu.com/v2/api/?login"
        $sPost = "ppui_logintime=14171&charset=utf-8&codestring=&token="&$token&"&isPhone=false&index=0&u=&safeflg=0&staticpage=http%3A%2F%2Fwww.baidu.com%2Fcache%2Fuser%2Fhtml%2Fjump.html&loginType=1&tpl=mn&callback=parent.bdPass.api.login._postCallback&username="&$Name&"&password="&$Pass&"&verifycode=&mem_pass=on"
        $rContext = _WinHTTP_GetRespond($MyOpen, $List, 4 + 2 + 1 + 256, 50000, $sPost, -1, "Content-Type: application/x-www-form-urlencoded")
        If @error Then
                Return -1
        EndIf
       
        MsgBox(0,0,BinaryToString($rContext, 4))
       
        $rContext = _WinHTTP_GetRespond($MyOpen ,'http://passport.baidu.com/center?t=1348581297',4+2,5000)
        If @error Then
                Return -1
        EndIf
        MsgBox(0,0,$rContext)
EndFunc

drunk 发表于 2012-9-25 19:03:37

$Name = 'plfeyp50205'
$Pass = 'hqacaf19005'
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("Post", "https://passport.baidu.com/v2/?login&fr=old", False)
$oHTTP.setRequestHeader("Cache-Control", "no-cache")
$oHTTP.setRequestHeader("Content-Type", "text/html;charset=gbk")
$oHTTP.setRequestHeader("Referer", "https://passport.baidu.com/v2/?login&fr=old")
$oHTTP.Send('callback=parent.bdPass.api.login._postCallback&'& _
'charset=utf-8&'& _
'codestring=&'& _
'index=0&'& _
'isPhone=false&'& _
'loginType=1&'& _
'password='&$Pass&'&'& _
'ppui_logintime=25422&'& _
'safeflg=0&'& _
'staticpage=https://passport.baidu.com/v2Jump.html&'& _
'token=4f2a39b477b52b8929ced1e57761d35a&'& _
'tpl=pp&'& _
'u=&'& _
'username='&$Name&'&'& _
'verifycode=')
$oHTTP.open("GET", "http://hi.baidu.com")
$oHTTP.send()
$Log = ($oHTTP.responsetext)
MsgBox(0,0,$Log)

drunk 发表于 2012-9-25 19:07:14

23行换成
$oHTTP.open("GET", "http://hi.baidu.com/home/?from=index&src=jump")

tryhi 发表于 2012-9-25 22:16:15

回复 4# suiyefeng


    哥们还加了QQ讨论,很热心啊

lpxx 发表于 2012-9-25 23:07:31

谢谢,学习一下
页: [1]
查看完整版本: 请教个POST问题(百度登陆)