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

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

查看: 5330|回复: 4

[其他] 求助httphelper获取到验证码后提交的问题

[复制链接]
发表于 2014-3-29 05:55:11 | 显示全部楼层 |阅读模式
获取验证码后提交  总是提示验证码错误
猜测可能是cookie重复获取了
站内搜索了一下 类似的问题   说是要把获取验证码的COOKIE放到“提交”操作里
我尝试了很久  还是提示验证码错误
希望版主大大还有朋友们帮我看看是怎么回事  多谢!没有找到发附件的地方 传到一个网站了www.jd0991.com/tp.zip


1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2014-3-29 08:58:36 | 显示全部楼层
直接贴一下主要代码就知道了,或者是提供下网址
发表于 2014-3-29 08:58:54 | 显示全部楼层
现在有权限上传了,刚注册第一交发帖子是没有权限的
 楼主| 发表于 2014-3-29 12:59:43 | 显示全部楼层
站长苏飞 发表于 2014-3-29 08:58
直接贴一下主要代码就知道了,或者是提供下网址

[C#] 纯文本查看 复制代码
//打开
        private void Form1_Load(object sender, EventArgs e)
        {
            
            HttpItem item = new HttpItem()
            {
                URL = "http://www.hb.xinhuanet.com/zhuanti/14one/cjxzpx/",//URL这里都是测试     必需项
                Method = "get",//URL     可选项 默认为Get
                //ResultCookieType = ResultCookieType.CookieCollection
            };
            //得到HTML代码
            HttpResult result = http.GetHtml(item);
            result = http.GetHtml(item);
            //web_cookie = result.Cookie;
            textBox3.Text = result.Html;
        }
        //进入到投票页面
        private void button1_Click(object sender, EventArgs e)
        {
            HttpItem item = new HttpItem();
            HttpResult result = http.GetHtml(item);
            item = new HttpItem()
            {
                URL = "http://202.123.110.196/govvote/vote/admin/survey/securitySubmit.jsp?surveyID=2134",//URL这里都是测试URl   必需项
                Encoding = null,//编码格式(utf-8,gb2312,gbk)     可选项 默认类会自动识别
                //Encoding = Encoding.Default,
                Method = "post",//URL     可选项 默认为Get
                Timeout = 100000,//连接超时时间     可选项默认为100000
                ReadWriteTimeout = 30000,//写入Post数据超时时间     可选项默认为30000
                IsToLower = false,//得到的HTML代码是否转成小写     可选项默认转小写
                Cookie = web_cookie,//字符串Cookie     可选项
                UserAgent = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36",//用户的浏览器类型,版本,操作系统     可选项有默认值
                Accept = "text/html, application/xhtml+xml, */*",//    可选项有默认值
                ContentType = "application/x-www-form-urlencoded",//返回类型    可选项有默认值
                Referer = "http://www.hb.xinhuanet.com/zhuanti/14one/cjxzpx/",//来源URL     可选项
                //Allowautoredirect = true,//是否根据301跳转     可选项
                //CerPath = "d:\\123.cer",//证书绝对路径     可选项不需要证书时可以不写这个参数
                //Connectionlimit = 1024,//最大连接数     可选项 默认为1024
                //Postdata = "C:\\PERKYSU_20121129150608_ScrubLog.txt",//Post数据     可选项GET时不需要写
                //PostDataType = PostDataType.FilePath,//默认为传入String类型,也可以设置PostDataType.Byte传入Byte类型数据
                //ProxyIp = "192.168.1.105:8015",//代理服务器ID 端口可以直接加到后面以:分开就行了    可选项 不需要代理 时可以不设置这三个参数
                //ProxyPwd = "123456",//代理服务器密码     可选项
                //ProxyUserName = "administrator",//代理服务器账户名     可选项
                ResultType = ResultType.Byte,//返回数据类型,是Byte还是String
                //PostdataByte = System.Text.Encoding.Default.GetBytes("test"),//如果PostDataType为Byte时要设置本属性的值
                //CookieCollection = new System.Net.CookieCollection(),//可以直接传一个Cookie集合进来
                Postdata = "selString=&askValue=&radioValue=&checkBoxValue=30166&selectValue=&radioRemarkValue=&checkRemarkValue=null&openfeatures2134=width%3D600%2Cheight%3D800%2Ctoolbar%3Dno%2Cmenubar%3Dno%2Cscrollbars%3Dyes%2Cresizable%3Dyes%2Clocation%3Dno%2Cstatus%3Dyes&4919_30166=30166&radioString=&checkBoxString=4919_30136%2C4919_30137%2C4919_30138%2C4919_30139%2C4919_30140%2C4919_30141%2C4919_30142%2C4919_30143%2C4919_30144%2C4919_30145%2C4919_30146%2C4919_30147%2C4919_30148%2C4919_30149%2C4919_30150%2C4919_30151%2C4919_30152%2C4919_30153%2C4919_30154%2C4919_30155%2C4919_30156%2C4919_30157%2C4919_30158%2C4919_30159%2C4919_30160%2C4919_30161%2C4919_30162%2C4919_30163%2C4919_30164%2C4919_30165%2C4919_30166%2C4919_30167%2C4919_30168%2C4919_30169%2C4919_30170%2C4919_30171%2C4919_30172%2C4919_30173%2C4919_30174%2C4919_30175%2C4919_30176%2C4919_30177%2C4919_30178%2C4919_30179%2C4919_30180%2C4919_30181%2C4919_30182%2C4919_30183%2C4919_30184%2C4919_30185%2C4919_30186%2C4919_30187%2C4919_30188%2C4919_30189%2C4919_30190%2C4919_30191%2C4919_30192%2C4919_30193%2C4919_30194%2C4919_30195%2C4919_30196%2C4919_30197%2C4919_30198%2C4919_30199%2C4919_30200%2C4919_30201%2C4919_30202%2C4919_30203%2C4919_30204%2C4919_30205%2C4919_30206%2C4919_30207%2C4919_30208%2C4919_30209%2C4919_30210%2C4919_30211%2C4919_30212%2C4919_30213%2C4919_30214%2C4919_30215%2C&selectString=&askString=&securitycode2134=1&votelimit2134=1&limittype2134=1"
            };

            //得到新的HTML代码
            result = http.GetHtml(item);
            textBox1.Text = result.Html;
            //web_cookie = result.Cookie.Replace("path=/,", "").Replace("path=/", "");
            textBox3.Text = web_cookie;
        }
        //获取验证码
        private void button2_Click(object sender, EventArgs e)
        {
            HttpItem item = new HttpItem()
            {
                URL = "http://202.123.110.196/govvote/voteSecuCode",//URL     必需项
                Encoding = null,//编码格式(utf-8,gb2312,gbk)     可选项 默认类会自动识别
                Referer = "http://202.123.110.196/govvote/vote/admin/survey/securitySubmit.jsp?surveyID=2134",
                //Cookie = web_cookie,
                //Encoding = Encoding.Default,
                ResultType = ResultType.Byte,
                ResultCookieType = ResultCookieType.CookieCollection,
            };
            //得到HTML代码
            HttpResult result = http.GetHtml(item);
            if (result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                //表示访问成功,具体的大家就参考HttpStatusCode类
            }
            //表示StatusCode的文字说明与描述
            string statusCodeDescription = result.StatusDescription;
            //把得到的Byte转成图片
            Image img = byteArrayToImage(result.ResultByte);
            pictureBox1.Image = img;
            //得到新的HTML代码
            result = http.GetHtml(item);
            web_cookie = result.Cookie.Replace("path=/,", "").Replace("path=/", "");
            textBox3.Text = web_cookie;
        }
        private Image byteArrayToImage(byte[] Bytes)
        {
            MemoryStream ms = new MemoryStream(Bytes);
            Image outputImg = Image.FromStream(ms);
            return outputImg;
        }
        //提交
        private void button3_Click(object sender, EventArgs e)
        {

            HttpItem item = new HttpItem();
            HttpResult result = http.GetHtml(item);
            item = new HttpItem()
            {
                URL = "http://202.123.110.196/govvote/vote/admin/survey/surveySubmit.jsp",//URL这里都是测试URl   必需项

                Encoding = null,//编码格式(utf-8,gb2312,gbk)     可选项 默认类会自动识别
                //Encoding = Encoding.Default,
                Method = "post",//URL     可选项 默认为Get
                Timeout = 100000,//连接超时时间     可选项默认为100000
                ReadWriteTimeout = 30000,//写入Post数据超时时间     可选项默认为30000
                IsToLower = false,//得到的HTML代码是否转成小写     可选项默认转小写
                Cookie = web_cookie,
                UserAgent = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36",//用户的浏览器类型,版本,操作系统     可选项有默认值
                Accept = "text/html, application/xhtml+xml, */*",//    可选项有默认值
                ContentType = "application/x-www-form-urlencoded",//返回类型    可选项有默认值
                Referer = "http://202.123.110.196/govvote/vote/admin/survey/securitySubmit.jsp?surveyID=2134",//来源URL     可选项
                Postdata = "scode2134="+ textBox2.Text.ToString().Trim() +"&radioString=&checkBoxString=4919_30136%2C4919_30137%2C4919_30138%2C4919_30139%2C4919_30140%2C4919_30141%2C4919_30142%2C4919_30143%2C4919_30144%2C4919_30145%2C4919_30146%2C4919_30147%2C4919_30148%2C4919_30149%2C4919_30150%2C4919_30151%2C4919_30152%2C4919_30153%2C4919_30154%2C4919_30155%2C4919_30156%2C4919_30157%2C4919_30158%2C4919_30159%2C4919_30160%2C4919_30161%2C4919_30162%2C4919_30163%2C4919_30164%2C4919_30165%2C4919_30166%2C4919_30167%2C4919_30168%2C4919_30169%2C4919_30170%2C4919_30171%2C4919_30172%2C4919_30173%2C4919_30174%2C4919_30175%2C4919_30176%2C4919_30177%2C4919_30178%2C4919_30179%2C4919_30180%2C4919_30181%2C4919_30182%2C4919_30183%2C4919_30184%2C4919_30185%2C4919_30186%2C4919_30187%2C4919_30188%2C4919_30189%2C4919_30190%2C4919_30191%2C4919_30192%2C4919_30193%2C4919_30194%2C4919_30195%2C4919_30196%2C4919_30197%2C4919_30198%2C4919_30199%2C4919_30200%2C4919_30201%2C4919_30202%2C4919_30203%2C4919_30204%2C4919_30205%2C4919_30206%2C4919_30207%2C4919_30208%2C4919_30209%2C4919_30210%2C4919_30211%2C4919_30212%2C4919_30213%2C4919_30214%2C4919_30215%2C&radioValue=&checkBoxValue=30166&surveyID=2134&view=&askString=&askValue=&selectString=&selectValue=&radioRemarkValue=&checkRemarkValue=null&enp_username=%E5%8C%BF%E5%90%8D%E7%94%A8%E6%88%B7&enp_usermail=%E5%8C%BF%E5%90%8D%E9%82%AE%E4%BB%B6&enp_country=&enp_province=&enp_sex=2&enp_degree=&enp_occupation=&enp_animals=&enp_star=&enp_blood=&enp_belief=&enp_idcard=&enp_phone=&enp_address=&enp_marriage=&votelimit2134=1&limittype2134=1&securitycode2134=1"
            };
            //得到新的HTML代码
            result = http.GetHtml(item);
            textBox1.Text = result.Html;

        }


tp.zip

76 KB, 下载次数: 46, 下载积分: 金钱 -1

发表于 2016-9-29 18:00:52 | 显示全部楼层
站长有解答?
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

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

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

© 2014-2021

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