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

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

楼主: 站长苏飞

[例子] C#使用HttpHelper类实现自动登录网易通行证,126,126登录的方法

[复制链接]
 楼主| 发表于 2013-3-4 20:16:04 | 显示全部楼层
hug_bear_mophi 发表于 2013-3-4 18:51
辛苦飞哥,得下班回家了,明天再试,感谢回复

好的这是网址http://www.sufeinet.com/thread-1072-1-1.html


1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2013-3-5 19:09:44 | 显示全部楼层
admin 发表于 2013-3-4 20:16
好的这是网址http://www.sufeinet.com/thread-1072-1-1.html

飞哥,登录163的这个例子需要人工拼接URL,我把截取到的PostData存入HttpItem.Postdata中不好使,这个HttpItem.Postdata什么情况下可以直接赋值呢,下面是代码,麻烦飞哥看一下
[code=csharp]        private void btnEnter_Click(object sender, EventArgs e)
        {
            HttpItem item = new HttpItem()
            {
                //URL = "https://reg.163.com/logins.jsp?url=&product=&savelogin=&outfoxer=&domains=" +
                //"&syscheckcode=034715eb7e1f16cd332e41f95e3303204ceadd7e&username="
                //+ txtUserName.Text.Trim() + "&password="
                //+ txtPwd.Text.Trim() + "&Submit=",
                URL = "https://reg.163.com/logins.jsp",
                Postdata = "url=&product=&savelogin=&outfoxer=&domains="
                + "&syscheckcode=034715eb7e1f16cd332e41f95e3303204ceadd7e&username="
                    + txtUserName.Text.Trim() + "&password="
                    + txtPwd.Text.Trim() + "&Submit=",
                Referer = "https://reg.163.com/logins.jsp",
                Method = "post",
            };
            HttpHelper http = new HttpHelper();
            string html = http.GetHtml(item);
            string cookie = item.Cookie;
            lblMessages.Text = "cookie:" + cookie + "\r\n\r\n";
            item.URL = "http://reg.163.com/Main.jsp";
            lblMessages.Text += http.GetHtml(item);
        }[/code]
发表于 2013-3-5 19:11:02 | 显示全部楼层
[code=csharp]        
private void btnEnter_Click(object sender, EventArgs e)
        {
            HttpItem item = new HttpItem()
            {
                //URL = "https://reg.163.com/logins.jsp?url=&product=&savelogin=&outfoxer=&domains=" +
                //"&syscheckcode=034715eb7e1f16cd332e41f95e3303204ceadd7e&username="
                //+ txtUserName.Text.Trim() + "&password="
                //+ txtPwd.Text.Trim() + "&Submit=",
                URL = "https://reg.163.com/logins.jsp",
                Postdata = "url=&product=&savelogin=&outfoxer=&domains="
                + "&syscheckcode=034715eb7e1f16cd332e41f95e3303204ceadd7e&username="
                    + txtUserName.Text.Trim() + "&password="
                    + txtPwd.Text.Trim() + "&Submit=",
                Referer = "https://reg.163.com/logins.jsp",
                Method = "post",
            };
            HttpHelper http = new HttpHelper();
            string html = http.GetHtml(item);
            string cookie = item.Cookie;
            lblMessages.Text = "cookie:" + cookie + "\r\n\r\n";
            item.URL = "http://reg.163.com/Main.jsp";
            lblMessages.Text += http.GetHtml(item);
        }[/code]
重发下代码,还不会发···
 楼主| 发表于 2013-3-5 19:14:21 | 显示全部楼层
hug_bear_mophi 发表于 2013-3-5 19:09
飞哥,登录163的这个例子需要人工拼接URL,我把截取到的PostData存入HttpItem.Postdata中不好使,这个Htt ...

http://www.sufeinet.com/thread-2002-1-1.html
发表于 2013-3-5 19:44:44 | 显示全部楼层
admin 发表于 2013-3-5 19:14
http://www.sufeinet.com/thread-2002-1-1.html

我下了新版的helper,人工拼接URL可以,分开写提示密码错误··· 还请飞哥说下HttpItem中postdata与url设置方法···
[code=csharp]        private void btnEnter_Click(object sender, EventArgs e)
        {
            HttpItem item = new HttpItem()
            {
                //URL = "https://reg.163.com/logins.jsp?url=&product=&savelogin=&outfoxer=&domains=" +
                //"&syscheckcode=034715eb7e1f16cd332e41f95e3303204ceadd7e&username="
                //+ txtUserName.Text.Trim() + "&password="
                //+ txtPwd.Text.Trim() + "&Submit=",
                URL = "https://reg.163.com/logins.jsp",
                Postdata = "url=&product=&savelogin=&outfoxer=&domains="
                + "&syscheckcode=034715eb7e1f16cd332e41f95e3303204ceadd7e&username="
                    + txtUserName.Text.Trim() + "&password="
                    + txtPwd.Text.Trim() + "&Submit=",
                Referer = "https://reg.163.com/logins.jsp",
                Method = "post",
                PostDataType = PostDataType.String,
            };
            HttpHelper http = new HttpHelper();
            HttpResult result = http.GetHtml(item);
            string cookie = result.Cookie;
            lblMessages.Text = "cookie:" + cookie + Environment.NewLine;
            item.URL = "http://reg.163.com/Main.jsp";
            lblMessages.Text += result.Html;
        }[/code]
发表于 2013-3-5 20:26:38 | 显示全部楼层
代码敲错了,没有重新访问,
lblMessages.Text +=http.GetHtml(item)。Html;
但是改后还是不行...
 楼主| 发表于 2013-3-6 12:45:33 | 显示全部楼层
PostDataType = PostDataType.String,如是设置为这样,Post格式就是
url=123&product=&savelogin=
你的设置方式没有错,应该是其他地方的问题
发表于 2013-3-18 12:13:47 | 显示全部楼层
顶楼内容始终为空白,这是咋回事啊。。。。
 楼主| 发表于 2013-3-18 12:21:25 | 显示全部楼层
duanweishi 发表于 2013-3-18 12:13
顶楼内容始终为空白,这是咋回事啊。。。。

那是因为你账户从未发过帖子,第一次发贴为了防止广告是需要审核的,通过之后就不会了,
http://www.sufeinet.com/thread-366-1-1.html
发表于 2013-5-12 14:57:55 | 显示全部楼层
最新的 HttpHelper2013-05-03.zip     下载下来 ,编译

        #region 普通类型
        ///<summary>
        ///采用https协议访问网络,根据传入的URl地址,得到响应的数据字符串。
        ///</summary>
        ///<param name="objhttpItem">参数列表</param>
        ///<returns>String类型的数据</returns>
        public HttpResult GetHtml(HttpItem objhttpItem)
        {
            try
            {
                //准备参数
                SetRequest(objhttpItem);
            }
            catch (Exception ex)
            {
                //HttpResult Result = new HttpResult()
                //{
                //    Cookie = "",
                //    Header = null,
                //    Html = ex.Message,
                //    StatusDescription = "配置参考时报错"
                //};
                //return Result;
            }
            //调用专门读取数据的类
            return GetHttpRequestData(objhttpItem);
        }
        #endregion

catch (Exception ex)里面的代码会报错
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

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

GMT+8, 2024-4-25 19:38

© 2014-2021

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