苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

查看: 3344|回复: 5

[其他] 猫扑登陆的代码?哪里不对?请苏老大指正!(二)

[复制链接]
发表于 2014-2-7 21:01:07 | 显示全部楼层 |阅读模式
就在昨天,在苏老大的指点下,完成了猫扑的正确登陆,但是我想带着COOKIE直接打开猫扑某个网页,为何又退出了登陆呢?
是我的cookie保存不对吗?


string Cookies = "";
        string[] tem;
        HttpHelper http = new HttpHelper();
        HttpResult result = null;
        private void button1_Click_1(object sender, EventArgs e)
        {
            //登陆
            HttpItem item = new HttpItem()
            {
                URL = "http://login.hi.mop.com/Login.do",
                Encoding = null,
                ContentType = "application/x-www-form-urlencoded",
                Method = "OST",
                Cookie = "",
                Postdata = "nickname=%E9%9B%A8%E9%AD%82%E5%A4%A9%E9%9B%AA&password=asd123258&origURL=http%3A%2F%2Fhi.mop.com%2FSysHome.do&loginregFrom=index&ss=10101",

            };
            result = http.GetHtml(item);
            Cookies += result.Cookie;
            item = new HttpItem()
            {
                URL = "http://home.hi.mop.com/Home.do?ss=10106",
                Encoding = null,
                ContentType = "application/x-www-form-urlencoded",
                Method = "GET",
                Cookie = Cookies,
                //  Referer="http://login.hi.mop.com/Login.do"
            };           
            result = http.GetHtml(item);
            Cookies += result.Cookie;   
            //此时已经显示登陆正常了,但打开某个网页为何又退出登陆了呢?
            item = new HttpItem()
            {
                URL = "http://tt.mop.com/read_14633343_1_0.html",
                Encoding = null,
                ContentType = "application/x-www-form-urlencoded",
                Method = "GET",
                Cookie = Cookies,
            };
            result = http.GetHtml(item);
            Cookies += result.Cookie;   
            webBrowser1.DocumentText = result.Html;

        }


1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
 楼主| 发表于 2014-2-7 21:01:50 | 显示全部楼层
Method = "OST",   显示成了
发表于 2014-2-7 21:28:11 | 显示全部楼层
     Encoding = null,
                ContentType = "application/x-www-form-urlencoded",
删除这两行
 楼主| 发表于 2014-2-7 21:35:04 | 显示全部楼层
故障依旧啊。。。。在webbowser中还是显示没登陆
发表于 2014-2-8 07:59:01 | 显示全部楼层
Cookies += result.Cookie;   谁叫你累加Cookie的,我那个例子或者教程中你看到有这样写的。直接用登录后的Cookiey就行了,不需要累加
 楼主| 发表于 2014-2-9 15:40:16 | 显示全部楼层
本帖最后由 ffww 于 2014-2-9 15:42 编辑

  string Cookies = "";
        string[] tem;
        HttpHelper http = new HttpHelper();
        HttpResult result = null;
        private void button1_Click_1(object sender, EventArgs e)
        {
            //登陆
            HttpItem item = new HttpItem()
            {
                URL = "http://login.hi.mop.com/Login.do",
                Method = "POST",
                Cookie = "",
                Postdata = "nickname=%E9%9B%A8%E9%AD%82%E5%A4%A9%E9%9B%AA&password=asd123258&origURL=http%3A%2F%2Fhi.mop.com%2FSysHome.do&loginregFrom=index&ss=10101",

            };
            result = http.GetHtml(item);
            Cookies = result.Cookie;
            item = new HttpItem()
            {
                URL = "http://home.hi.mop.com/Home.do?ss=10106",
                Method = "GET",
                Cookie = Cookies,
                Referer = "http://login.hi.mop.com/Login.do"
            };
            result = http.GetHtml(item);

           // 打开某个网页
            item = new HttpItem()
            {
                URL = "http://tt.mop.com/read_14633343_1_0.html",
                Method = "GET",
                Cookie = Cookies,
            };
            result = http.GetHtml(item);
            webBrowser1.DocumentText = result.Html;
        }
结果:在webbowser中还是显示没登陆
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

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

GMT+8, 2025-2-28 17:59

© 2014-2021

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