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

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

查看: 2937|回复: 3

[例子] 带验证证的登陆问题

[复制链接]
发表于 2015-5-29 21:40:31 | 显示全部楼层 |阅读模式
本帖最后由 liaochen 于 2015-5-29 21:59 编辑

HttpHelper http = new HttpHelper();
        HttpItem item = null;
        HttpResult result = new HttpResult();
        string strCookie = string.Empty;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
        private void button1_Click(object sender, EventArgs e)          //登陆
        {
            item = new HttpItem()
            {
                URL = "http://www.sbanzu.com/checkuser.asp",
                Method = "post",
                Postdata = string.Format(@"Parameter Name=Value&UserName=快乐的可乐瓶&Password=19820509&code={0}&URl=/", textBox1.Text),
                Cookie = strCookie,
            };
            result = http.GetHtml(item);

            strCookie = result.Cookie;
            outobj(result.Html);
        }

        private void pictureBox1_Click(object sender, EventArgs e)          //显示验证码
        {
            item = new HttpItem()
            {
                URL = "http://www.sbanzu.com/sbanzu/GetCode.asp?r",
                Method = "get",
                ResultType = ResultType.Byte,
            };

            result =  http.GetHtml(item);
            strCookie = result.Cookie;

            if (result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                string statusCodeDescription = result.StatusDescription;
                MemoryStream ms = new MemoryStream(result.ResultByte);
                Image img = Image.FromStream(ms);
                pictureBox1.Image = img;
            }
        }

        private void outobj(string strhtml)             //显示出来
        {
            richTextBox1.Clear();
            richTextBox1.AppendText(strhtml);
            webBrowser1.ScriptErrorsSuppressed = true;
            webBrowser1.DocumentText = strhtml;
        }

www.sbanzu.com
用户名:快乐的可乐瓶
密码:19820509
帮我看看吧,搞几天了,人都要疯了总是登陆不了




1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2015-5-29 21:42:38 | 显示全部楼层
咋啦小伙伴
 楼主| 发表于 2015-5-29 21:58:46 | 显示全部楼层

帮我看下啊,登陆不了,我搞了几天了
发表于 2015-6-1 01:00:24 来自移动端 | 显示全部楼层
你的用户名有中文,postdata要urlencode编码
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

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

GMT+8, 2024-5-29 04:11

© 2014-2021

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