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

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

查看: 4932|回复: 7

[求助] 求助下,大众点评注册界面的验证码获取问题

[复制链接]
发表于 2015-1-9 17:32:07 | 显示全部楼层 |阅读模式
本帖最后由 diorlv2010 于 2015-1-9 17:36 编辑

验证码连接生成了,为什么获取回来的数据为空抓取的格式为
http://www.dianping.com/JValidateCode.jpg?xx=120
我写的也这个url也可以生成如上这个连接,但是调用GetHtml方法,获取不到验证码信息

string imgurl = string.Format("http://www.dianping.com/JValidateCode.jpg?xx={0}",r.Next(0, 1000));



1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2015-1-9 17:44:17 | 显示全部楼层
http://www.sufeinet.com/thread-10024-1-1.html
HttpHelper http = new HttpHelper();            HttpItem item = new HttpItem()            {                URL = "http://www.sufeinet.com/template/veikei_dz_life_20130810_plus/images/logo.png?2014-06-06",                Method = "get",//URL     可选项 默认为Get                   ResultType = ResultType.Byte            };            HttpResult result = http.GetHtml(item);            Image img = byteArrayToImage(result.ResultByte);
 楼主| 发表于 2015-1-9 17:54:00 | 显示全部楼层
水手 发表于 2015-1-9 17:44
http://www.sufeinet.com/thread-10024-1-1.html
HttpHelper http = new HttpHelper();            HttpI ...

首先感谢下,但是没有解决我说的问题,这个URL执行后,http.GetHtml(item);方法返回空
 楼主| 发表于 2015-1-9 17:57:00 | 显示全部楼层
水手 发表于 2015-1-9 17:44
http://www.sufeinet.com/thread-10024-1-1.html
HttpHelper http = new HttpHelper();            HttpI ...

他这个URL不知道为什么,在地址栏运行打开为空,但是连接到论坛点击就能打开图片
发表于 2015-1-10 12:29:16 | 显示全部楼层
cookie呗
回复

使用道具 举报

发表于 2015-1-11 09:47:51 | 显示全部楼层
嗯,这两天忙,没登陆论坛。
今天刚看到你的问题回复,测试看了下,问题出在Referer的参数,这个不为空才能返回图片。
验证码问题.png
代码部分用论坛的HttpHelper框架写,很方便。

  HttpHelper http = new HttpHelper();
        HttpItem item = null;
        HttpResult result = null;
        private void button1_Click(object sender, EventArgs e)
        {
            item = new HttpItem
            {
                URL = "http://www.dianping.com/JValidateCode.jpg?xx=120",
                Method = "get",//URL     可选项 默认为Get   
                ResultType = ResultType.Byte,               
                Referer = "http://www.sufeinet.com"
            };
             result = http.GetHtml(item);
            Image img = byteArrayToImage(result.ResultByte);
            pictureBox1.Image = img;
        }
        private Image byteArrayToImage(byte[] Bytes)
        {
            MemoryStream ms = new MemoryStream(Bytes);
            return Bitmap.FromStream(ms, true);
        }
发表于 2015-1-11 09:50:28 | 显示全部楼层
Referer的值可以随意写“11111”,“sdfsd”,不为空即可。验证码请求对来源地址有验证。
 楼主| 发表于 2015-1-13 09:37:42 | 显示全部楼层
谢谢水手老师,这几天生病,今早试了下,果然是这个问题,谢谢您的指导
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

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

GMT+8, 2024-5-29 16:09

© 2014-2021

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