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

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

查看: 3892|回复: 7

[求助] 简单的登录,怎么不行啊,高手给看看

[复制链接]
发表于 2015-3-6 09:55:00 | 显示全部楼层 |阅读模式
http://yunvs.com/index.php?m=member&siteid=1
用户名dxwang
密码qw123123

代码如下
[C#] 纯文本查看 复制代码
//string url = textBox1.Text;
            HttpHelper http = new HttpHelper();
            //创建Httphelper参数对象
            HttpItem item = new HttpItem()
            {
                URL = "http://yunvs.com/index.php?m=member&c=index&a=login&forward=http%3A%2F%2Fyunvs.com%2Findex.php%3Fm%3Dmember%26c%3Dindex",
                Referer = "http://yunvs.com/index.php?m=member&c=index",
                Host = "yunvs.com",
                Postdata ="forward=http%253A%252F%252Fyunvs.com%252Findex.php%253Fm%253Dmember%2526c%253Dindex&username=dxwang&password=qw123123&cookietime=2592000&dosubmit=%B5%C7%C2%BC",// string.Format("method=login&uid={0}&pwdtype=&hardInfo=&logintype=common&flowno=&usbkeySn=&usbkeyData=&mac=>ja_dating_login_type=0&availHeight=958&YYBFW=10&BranchCode=3119&BranchName=上海威海路证券营业部&Page=&selectBranchCode=7001&countType=Z&inputid={1}&trdpwd={3}&AppendCode={2}", "520223", "7385", textBox13.Text, GetPass("520223"))
                ContentType = "application/x-www-form-urlencoded",
                UserAgent="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0",
                ResultCookieType = ResultCookieType.CookieCollection
            };
            //item.Header.Add("X-Prototype-Version: 1.5.0_rc1");
            //item.Header.Add("X-Requested-With: XMLHttpRequest");

            //请求的返回值对象
            HttpResult result = http.GetHtml(item);
            //获取请求的Cookie
            CookieCollection cookie = result.CookieCollection;

            // 第二次使用Cookie
            //创建Httphelper参数对象
            item = new HttpItem()
            {
                URL = "http://yunvs.com/index.php?m=member&c=index",
                Referer = "http://yunvs.com/index.php?m=member&c=index",
                Host = "yunvs.com",
                Method = "get",
                PostEncoding = Encoding.Default,
                CookieCollection = cookie,//把Cookie写入请求串中
                ResultCookieType = ResultCookieType.CookieCollection,

            };
            //请求的返回值对象
            result = http.GetHtml(item);

            //获取Html
            string html = result.Html;
            textBox2.Text = html;


为什么不行,高手给看看



1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2015-3-6 10:13:32 | 显示全部楼层
[C#] 纯文本查看 复制代码
            HttpHelper http = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "http://yunvs.com/index.php?m=member&c=index&a=login",//URL     必需项    
                Method = "post",//URL     可选项 默认为Get 
                Postdata = "forward=&username=dxwang&password=qw123123&cookietime=2592000&dosubmit=%B5%C7%26%23160%3B%26%23160%3B%C2%BC",//Post
                ContentType = "application/x-www-form-urlencoded",//返回类型    可选项有默认值 
                ResultType = ResultType.String
            };
            HttpResult result = http.GetHtml(item);
            string html = result.Html;
            string cookie = result.Cookie;

 楼主| 发表于 2015-3-6 10:38:07 | 显示全部楼层
为什么返回的cookie要string类型的呀

登录后访问http://yunvs.com/index.php?m=member会员后台还是提示没权限

[C#] 纯文本查看 复制代码
  HttpHelper http = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "http://yunvs.com/index.php?m=member&c=index&a=login",//URL     必需项    
                Method = "post",//URL     可选项 默认为Get 
                Postdata = "forward=&username=dxwang&password=qw123123&cookietime=2592000&dosubmit=%B5%C7%26%23160%3B%26%23160%3B%C2%BC",//Post
                ContentType = "application/x-www-form-urlencoded",//返回类型    可选项有默认值 
                ResultType = ResultType.String
            };
            HttpResult result = http.GetHtml(item);
           
            CookieCollection cookie = result.CookieCollection;
           

            // 第二次使用Cookie
            //创建Httphelper参数对象
            item = new HttpItem()
            {
                URL = "http://yunvs.com/index.php?m=member",
                Referer = "http://yunvs.com/index.php?m=member",
                Host = "yunvs.com",
                Method = "get",
                PostEncoding = Encoding.Default,
                CookieCollection = cookie,//把Cookie写入请求串中
                ResultCookieType = ResultCookieType.CookieCollection,

            };
            //请求的返回值对象
            result = http.GetHtml(item);
            //获取Html
            string html = result.Html;
发表于 2015-3-6 10:40:50 | 显示全部楼层
登录成功了吧,那就格式化一下Cookie
 楼主| 发表于 2015-3-6 10:41:35 | 显示全部楼层
不会啊。。咋弄呢
 楼主| 发表于 2015-3-6 10:43:16 | 显示全部楼层
登录成功后
返回的cookie是
"HPSESSID=vdc1ufvcaj4cl1abei32pf8te1; path=/,bqGOO_auth=FAUWZjdmGloaFDoGBgZxFWUWJigDQw10N2EFPA4DEAIGAXkZchYlMgN1N3Y0ZjApGiImeA%3D%3D,bqGOO__userid=Zg1TAkE%3D,bqGOO__username=MUwRUBtX,bqGOO__groupid=Zw%3D%3D,bqGOO__nickname=hvfdlkQBcF91YA%3D%3D,bqGOO_cookietime=ZQ%3D%3D; expires=Fri, 06-Mar-2015 01:42:21 GMT,SERVERID=5aa44b553a6fe61f13de1d9ab723b710|1425609741|1425609741ath=/"

下面该咋弄呢
发表于 2015-3-6 11:03:55 | 显示全部楼层
http://www.sufeinet.com/thread-10019-1-1.html 我写的教程你们如果看一下,或者是能记住有什么功能就好了,总是都不带看的。http://httphelper.sufeinet.com/Course.aspx
发表于 2015-3-6 14:53:53 | 显示全部楼层
dxwang 发表于 2015-3-6 10:43
登录成功后
返回的cookie是
"PHPSESSID=vdc1ufvcaj4cl1abei32pf8te1; path=/,bqGOO_auth=FAUWZjdmGloaFDo ...

怎么这么急躁干嘛呢 , 花半个小时认真看一遍资料. 不看资料的话耽误的不仅仅是这点时间了.
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

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

GMT+8, 2024-5-4 00:04

© 2014-2021

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