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

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

查看: 4767|回复: 2

[HttpHelper] post登录Dz论坛的时候 总是提示验证码错误

[复制链接]
发表于 2016-10-24 10:19:41 | 显示全部楼层 |阅读模式
飞哥 Post登录dz论坛的时候总是提示验证码错误  

dz论坛的验证码地址是2次get得到的 我也是加了2次get

也代了cookies请求验证码 代了cookies post登录


一直都提示验证码错误  昨天烦了一天了 求飞哥帮助

辛苦飞哥了

[C#] 纯文本查看 复制代码
  public partial class Form1 : Form
    {
        string formhash;
        string loginHash;
        string secondHash;
        string cookiesQian;
        public Form1()
        {

            InitializeComponent();
            HttpHelper help = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "http://data.loulanpo.com/member.php?mod=logging&action=login",
                Method = "get",
                ContentType = "text/html; charset=gbk",

            };

            HttpResult result = help.GetHtml(item);
            string html = result.Html;
            cookiesQian = result.Cookie;
            string idhash = HttpHelper.GetBetweenHtml(html, "<span id=\"seccode_", "\"></span>");
            formhash = HttpHelper.GetBetweenHtml(html, "<input type=\"hidden\" name=\"formhash\" value=\"", "\" />");
            loginHash = HttpHelper.GetBetweenHtml(html, "loginhash=", "\"");
            secondHash = HttpHelper.GetBetweenHtml(html, "<span id=\"seccode_", "\"></span>");
            string sssss = ConvertDateTimeInt(DateTime.Now);
            HttpItem itemQian = new HttpItem()
            {
                URL = "http://data.loulanpo.com/misc.php?mod=seccode&action=update&idhash=" + idhash + "&"+ ConvertDateTimeInt(DateTime.Now) + "&modid=member::logging",
                Referer = "http://data.loulanpo.com/member.php?mod=logging&action=login",
                Method ="GET",
                Cookie =cookiesQian,
            };
            HttpResult resultQian = help.GetHtml(itemQian);
            string update = HttpHelper.GetBetweenHtml(resultQian.Html, "height=\"30\" src=\"", "\" class=");
            HttpItem image1 = new HttpItem()
            {
                URL = "http://data.loulanpo.com/" + update,
                Referer = "http://data.loulanpo.com/member.php?mod=logging&action=login",
                Method = "GET",//URL  可选项 默认为Get   
                ContentType = "image/png",
                Cookie = cookiesQian,
            };
            this.pictureBox1.Image = help.GetImage(image1);
        }


        /// <summary>
        /// 将c# DateTime时间格式转换为Unix时间戳格式
        /// </summary>
        /// <param name="time">时间</param>
        /// <returns>long</returns>
        public static string ConvertDateTimeInt(System.DateTime time)
        {
            //double intResult = 0;
            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0));
            long t = (time.Ticks - startTime.Ticks) / 10;
            string s = "0." + t.ToString();
            return s;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            HttpHelper help = new HttpHelper();

            HttpItem item2 = new HttpItem()
            {
                URL = "http://data.loulanpo.com/member.php?mod=logging&action=login&loginsubmit=yes&loginhash=" + loginHash + "&inajax=1",
                Method = "POST",
                ContentType = "application/x-www-form-urlencoded",
                Postdata = "formhash=" + formhash + "&referer=http%3A%2F%2Fdata.loulanpo.com%2F.%2F&loginfield=username&username=xioao&password=qw4&questionid=0&answer=&seccodehash=" + secondHash + "&seccodemodid=member%3A%3Alogging&seccodeverify=" + this.textBox3.Text.Trim(),
                Cookie = cookiesQian,
            };
            string xxxx = "formhash=" + formhash + "&referer=http%3A%2F%2Fdata.loulanpo.com%2F.%2F&loginfield=username&username=xiabao&password=qw34&questionid=0&answer=&seccodehash=" + secondHash + "&seccodemodid=member%3A%3Alogging&seccodeverify=" + this.textBox3.Text.Trim();
            HttpResult result = help.GetHtml(item2);
            string sssswd = result.Html;
            string cookies = result.Cookie;
        }

    }



1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2016-10-24 12:04:52 | 显示全部楼层
cookie不对,用验证码界面返回的Cookie去处理试试
 楼主| 发表于 2016-10-24 14:54:15 | 显示全部楼层
站长苏飞 发表于 2016-10-24 12:04
cookie不对,用验证码界面返回的Cookie去处理试试

老大 post用的验证码返回的cookies的 还是提示同样的错误 验证码错误
[C#] 纯文本查看 复制代码
   public partial class Form1 : Form
    {
        string formhash;
        string loginHash;
        string secondHash;
        string cookiesQian;
        string cookiesHou;
        public Form1()
        {

            InitializeComponent();
            HttpHelper help = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "http://data.loulanpo.com/member.php?mod=logging&action=login",
                Method = "get",
                ContentType = "text/html; charset=gbk",

            };

            HttpResult result = help.GetHtml(item);
            string html = result.Html;
            cookiesQian = result.Cookie;
            string idhash = HttpHelper.GetBetweenHtml(html, "<span id=\"seccode_", "\"></span>");
            formhash = HttpHelper.GetBetweenHtml(html, "<input type=\"hidden\" name=\"formhash\" value=\"", "\" />");
            loginHash = HttpHelper.GetBetweenHtml(html, "loginhash=", "\"");
            secondHash = HttpHelper.GetBetweenHtml(html, "<span id=\"seccode_", "\"></span>");
            string sssss = ConvertDateTimeInt(DateTime.Now);
            HttpItem itemQian = new HttpItem()
            {
                URL = "http://data.loulanpo.com/misc.php?mod=seccode&action=update&idhash=" + idhash + "&"+ ConvertDateTimeInt(DateTime.Now) + "&modid=member::logging",
                Referer = "http://data.loulanpo.com/member.php?mod=logging&action=login",
                Method ="GET",
                Cookie =cookiesQian,
            };
            HttpResult resultQian = help.GetHtml(itemQian);
            string update = HttpHelper.GetBetweenHtml(resultQian.Html, "height=\"30\" src=\"", "\" class=");
            HttpItem image1 = new HttpItem()
            {
                URL = "http://data.loulanpo.com/" + update,
                Referer = "http://data.loulanpo.com/member.php?mod=logging&action=login",
                Method = "GET",//URL  可选项 默认为Get   
                ContentType = "image/png",
                Cookie = cookiesQian,
            };
            this.pictureBox1.Image = help.GetImage(image1);
            cookiesHou = image1.Cookie;
        }


        /// <summary>
        /// 将c# DateTime时间格式转换为Unix时间戳格式
        /// </summary>
        /// <param name="time">时间</param>
        /// <returns>long</returns>
        public static string ConvertDateTimeInt(System.DateTime time)
        {
            //double intResult = 0;
            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0));
            long t = (time.Ticks - startTime.Ticks) / 10;
            string s = "0." + t.ToString();
            return s;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            HttpHelper help = new HttpHelper();

            HttpItem item2 = new HttpItem()
            {
                URL = "http://data.loulanpo.com/member.php?mod=logging&action=login&loginsubmit=yes&loginhash=" + loginHash + "&inajax=1",
                Method = "POST",
                ContentType = "application/x-www-form-urlencoded",
                Postdata = "formhash=" + formhash + "&referer=http%3A%2F%2Fdata.loulanpo.com%2F.%2F&loginfield=username&username=xibao&password=qw34&questionid=0&answer=&seccodehash=" + secondHash + "&seccodemodid=member%3A%3Alogging&seccodeverify=" + this.textBox3.Text.Trim(),
                Cookie = cookiesHou,
            };
            string xxxx = "formhash=" + formhash + "&referer=http%3A%2F%2Fdata.loulanpo.com%2F.%2F&loginfield=username&username=xiaao&password=qw4&questionid=0&answer=&seccodehash=" + secondHash + "&seccodemodid=member%3A%3Alogging&seccodeverify=" + this.textBox3.Text.Trim();
            HttpResult result = help.GetHtml(item2);
            string sssswd = result.Html;
            string cookies = result.Cookie;
        }
    }

您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

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

GMT+8, 2024-11-23 09:45

© 2014-2021

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