http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 12312|回复: 13

[求助] 输入验证码后登录失败

[复制链接]
发表于 2014-7-5 00:27:17 | 显示全部楼层 |阅读模式
最近在研究模拟登录,用了站长的helper类,受益匪浅,可是下面这个网站死活登录不上去,能否帮忙看一下哈。
[C#] 纯文本查看 复制代码
   string code_cookie;

        public MainWindow()
        {
            InitializeComponent();

            HttpHelper http = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "http://login.ebdoor.com/Resource/ValidateCode/ValidateCode.aspx",//URL     必需项    
                ResultType = ResultType.Byte
            };
            HttpResult result = http.GetHtml(item);
            code_cookie = result.Cookie;
            this.image1.Source = byteArrayToImage(result.ResultByte);
        }

        private BitmapImage byteArrayToImage(byte[] Bytes)
        {
            BitmapImage result = new BitmapImage();
            result.BeginInit();
            result.StreamSource = new MemoryStream(Bytes);
            result.EndInit();
            return result;
        }

        private void Login_Click(object sender, RoutedEventArgs e)
        {
            HttpHelper http = new HttpHelper();
            string fr_gdcode = textBox1.Text.Trim();

            string Ebdoor_PostData = "__EVENTTARGET=LinkButton_Submit&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUKLTQ1NTQyMTQzOGRk&TextBox_LoginAccount=shbounty&TextBox_LoginPassword=123456&Hidden_Valid=c8050f53-11cf-4660-ada3-b69854b7beb3&TextBox_ValidateCode={0}";

            HttpItem item = new HttpItem()
            {
                URL = "http://login.ebdoor.com/member/login.aspx", 
                Method = "post",     
                Referer = "http://login.ebdoor.com/member/login.aspx",
                Host = "login.ebdoor.com",
                Postdata = String.Format(Ebdoor_PostData, fr_gdcode),
                ContentType = "application/x-www-form-urlencoded",
                Encoding = Encoding.UTF8,
                Cookie = code_cookie
               
            };
            item.Header.Add("DNT", "1");
            HttpResult result = http.GetHtml(item);

            if (result.StatusCode != HttpStatusCode.OK){
                MessageBox.Show("登录失败");
            }

        }

GetEbdoor.zip

84.29 KB, 下载次数: 33, 下载积分: 金钱 -1

代码



1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2014-7-5 00:59:08 | 显示全部楼层
帖下你的抓包信息看看吧
发表于 2014-7-5 00:59:53 | 显示全部楼层
建议用登录页面的cookie获取图片
 楼主| 发表于 2014-7-5 10:45:04 | 显示全部楼层
站长苏飞 发表于 2014-7-5 00:59
建议用登录页面的cookie获取图片

谢谢您的迅速回复,我试一下哈
 楼主| 发表于 2014-7-5 12:06:47 | 显示全部楼层
站长苏飞 发表于 2014-7-5 00:59
建议用登录页面的cookie获取图片

按照您说的用登录页面的cookie获取图片,我试了一下,还是不行。
不知为何Get不到登录画面HTML呢
验证码取得没有问题。

Get登录画面的抓包信息。
HTTP/1.0 302 Moved Temporarily
Cache-Control: private
Content-Type: text/html; charset=utf-8
Location: http://login.ebdoor.com/GET_USER ... AVE_USER_TOKEN.ASPX
Server: Microsoft-IIS/7.5
Set-Cookie: ASP.NET_SessionId=1qkxzpwkpaj1w2dq23uvbk4y; domain=ebdoor.com; path=/; HttpOnly
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Sat, 05 Jul 2014 04:04:20 GMT
Content-Length: 292
X-Cache: MISS from CT-TJTG-19-12.fastcdn.com
X-Cache: MISS from CNC-SDJN-209-29.fastcdn.com
Connection: keep-alive

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="http://login.ebdoor.com/GET_USER_TOKEN.aspx?UserVisitUrl=http%3a%2f%2flogin.ebdoor.com%2fMember%2fLogin.aspx&amp;ReturnUrl=http%3a%2f%2flogin.ebdoor.com%2fSAVE_USER_TOKEN.ASPX">here</a>.</h2>
</body></html>


[C#] 纯文本查看 复制代码
 string code_cookie;

        public MainWindow()
        {
            InitializeComponent();

            HttpHelper http = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "http://login.ebdoor.com/Member/Login.aspx",
                ResultType = ResultType.Byte,
                ProxyIp = "ieproxy"
            };
            item.Header.Add("DNT", "1");

            HttpResult result = http.GetHtml(item);
            code_cookie = result.Cookie;

             item = new HttpItem()
            {
                URL = "http://login.ebdoor.com/Resource/ValidateCode/ValidateCode.aspx",  
                ResultType = ResultType.Byte,
                Cookie = code_cookie,
                ProxyIp = "ieproxy"
            };
             result = http.GetHtml(item);
            this.image1.Source = byteArrayToImage(result.ResultByte);
        }

        private BitmapImage byteArrayToImage(byte[] Bytes)
        {
            BitmapImage result = new BitmapImage();
            result.BeginInit();
            result.StreamSource = new MemoryStream(Bytes);
            result.EndInit();
            return result;
        }

        private void Login_Click(object sender, RoutedEventArgs e)
        {
            HttpHelper http = new HttpHelper();
            string fr_gdcode = textBox1.Text.Trim();

            string Ebdoor_PostData = "__EVENTTARGET=LinkButton_Submit&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUKLTQ1NTQyMTQzOGRk&TextBox_LoginAccount=shbounty&TextBox_LoginPassword=123456&Hidden_Valid=c8050f53-11cf-4660-ada3-b69854b7beb3&TextBox_ValidateCode={0}";

            HttpItem item = new HttpItem()
            {
                URL = "http://login.ebdoor.com/member/login.aspx", 
                Method = "post",     
                Referer = "http://login.ebdoor.com/member/login.aspx",
                Host = "login.ebdoor.com",
                Postdata = String.Format(Ebdoor_PostData, fr_gdcode),
                ContentType = "application/x-www-form-urlencoded",
                Encoding = Encoding.UTF8,
                Cookie = code_cookie,
                ProxyIp = "ieproxy"
               
            };
            item.Header.Add("DNT", "1");
            HttpResult result = http.GetHtml(item);

            if (result.StatusCode != HttpStatusCode.OK){
                MessageBox.Show("登录失败");
            }

        }
发表于 2014-7-5 12:16:03 | 显示全部楼层
这是跳转了,应该就成功了,获取cookie直接跳转
发表于 2014-7-5 12:55:26 | 显示全部楼层
站长苏飞 发表于 2014-7-5 12:16
这是跳转了,应该就成功了,获取cookie直接跳转

Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/msword, */*
 楼主| 发表于 2014-7-5 13:20:19 | 显示全部楼层
站长苏飞 发表于 2014-7-5 12:16
这是跳转了,应该就成功了,获取cookie直接跳转

谢谢,回复太快了,这个站必火!!


这是post的抓包,请帮我看一下吧
-----------------------------------
POST http://login.ebdoor.com/member/login.aspx HTTP/1.1
DNT: 1
Accept: text/html, application/xhtml+xml, */*
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
Cookie: ASP.NET_SessionId=vuecasvtcaytwi0t3wx3niua; domain=ebdoor.com; path=/; HttpOnly
Referer: http://login.ebdoor.com/member/login.aspx
Host: login.ebdoor.com
Content-Length: 222
Expect: 100-continue
Connection: Keep-Alive

__EVENTTARGET=LinkButton_Submit&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUKLTQ1NTQyMTQzOGRk&TextBox_LoginAccount=shbounty&TextBox_LoginPassword=123456&Hidden_Valid=c8050f53-11cf-4660-ada3-b69854b7beb3&TextBox_ValidateCode=zcbi

--------------------------------------

post之后返回的statusCode=found,就是失败了吧。
想登录后跳转到下面这个页面,始终也不行。
http://my.ebdoor.com/Member/index.aspx
发表于 2014-7-5 14:22:03 | 显示全部楼层
返回包是什么,你自己写的返回的什么
 楼主| 发表于 2014-7-5 14:57:58 | 显示全部楼层
站长苏飞 发表于 2014-7-5 14:22
返回包是什么,你自己写的返回的什么

HTTP/1.0 302 Moved Temporarily
Cache-Control: private
Content-Type: text/html; charset=utf-8
Location: http://login.ebdoor.com/GET_USER ... AVE_USER_TOKEN.ASPX
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Sat, 05 Jul 2014 06:56:51 GMT
Content-Length: 292
X-Cache: MISS from CT-BFDX-186-80.fastcdn.com
X-Cache: MISS from CNC-SDJN-209-29.fastcdn.com
Connection: keep-alive

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="http://login.ebdoor.com/GET_USER_TOKEN.aspx?UserVisitUrl=http%3a%2f%2flogin.ebdoor.com%2fmember%2flogin.aspx&amp;ReturnUrl=http%3a%2f%2flogin.ebdoor.com%2fSAVE_USER_TOKEN.ASPX">here</a>.</h2>
</body></html>
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2024-11-14 14:50

© 2014-2021

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