找回密码
 加入
搜索
查看: 6886|回复: 5

[IE类操作] 请教个POST问题(百度登陆)

  [复制链接]
发表于 2012-9-25 18:32:39 | 显示全部楼层 |阅读模式
悬赏500金钱已解决
这两段代码均登陆不上去,不知原因


#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)



附件: 您需要 登录 才可以下载或查看,没有账号?加入
发表于 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[0])

        $token = StringRegExp($rContext[0], "login_token='(.*?)';", 3)
        If IsArray($token) Then 
                $token = $token[0]
        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[0], 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[0])
EndFunc

评分

参与人数 1金钱 +70 贡献 +10 收起 理由
tryhi + 70 + 10 哥们很热心

查看全部评分

发表于 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)

评分

参与人数 1金钱 +50 贡献 +5 收起 理由
tryhi + 50 + 5 多谢关注,测试一下先

查看全部评分

发表于 2012-9-25 19:07:14 | 显示全部楼层
23行换成
$oHTTP.open("GET", "http://hi.baidu.com/home/?from=index&src=jump")
 楼主| 发表于 2012-9-25 22:16:15 | 显示全部楼层
回复 4# suiyefeng


    哥们还加了QQ讨论,很热心啊
发表于 2012-9-25 23:07:31 | 显示全部楼层
谢谢,学习一下
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-18 16:43 , Processed in 0.107146 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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