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

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

查看: 8601|回复: 7

[求助] 采集淘宝分页数据

[复制链接]
发表于 2013-7-12 10:27:45 | 显示全部楼层 |阅读模式
有问题请教啊
我遇到一个,采集淘宝彩票网站的数据,只能获取第一页,剩下的页就获取不到
http://caipiao.taobao.com/lottery/order/united_hall.htm?spm=0.0.0.0.DDPcSQ&lottery_type=3D
他这个是不是加了cookie验证啥的,第二页数据 通过下面的网站也不行,
http://caipiao.taobao.com/lottery/order/united_hall.htm?_tb_token_=e56e8b750b7b3&page=2&lottery_type=3D&sort_obj=process&sort=desc&change_sort=&lowAmount=&highAmount=&play_type=0&issue=2013186&status=1&amountSec=0-0&commissionRate=-1&creator=
我把_tb_token_替换了也不行,不知道怎么办了,请高手帮忙解决啊







1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2013-7-12 10:33:42 | 显示全部楼层
可以呀,直接写代码就行
[code=csharp]            HttpHelper http = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "http://caipiao.taobao.com/lottery/order/united_hall.htm?_tb_token_=ee91be7eab33a&page=2&lottery_type=3D&sort_obj=process&sort=desc&change_sort=&lowAmount=&highAmount=&play_type=0&issue=2013186&status=1&amountSec=0-0&commissionRate=-1&creator=",//URL     必需项   
                Method = "get",//URL     可选项 默认为Get   
                IsToLower = false,//得到的HTML代码是否转成小写     可选项默认转小写   
                Cookie = "",//字符串Cookie     可选项   
                Referer ="",//来源URL     可选项   
                Postdata = "",//Post数据     可选项GET时不需要写   
                Timeout = 100000,//连接超时时间     可选项默认为100000   
                ReadWriteTimeout = 30000,//写入Post数据超时时间     可选项默认为30000   
                UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",//用户的浏览器类型,版本,操作系统     可选项有默认值   
                ContentType = "text/html",//返回类型    可选项有默认值   
                Allowautoredirect = false,//是否根据301跳转     可选项   
                //CerPath = "d:\123.cer",//证书绝对路径     可选项不需要证书时可以不写这个参数   
                //Connectionlimit = 1024,//最大连接数     可选项 默认为1024                    ProxyIp = "",//代理服务器ID     可选项 不需要代理 时可以不设置这三个参数   
                //ProxyPwd = "123456",//代理服务器密码     可选项   
                //ProxyUserName = "administrator",//代理服务器账户名     可选项   
            };
            HttpResult result = http.GetHtml(item);
            string html = result.Html;
            string cookie = result.Cookie;
[/code]
 楼主| 发表于 2013-7-12 10:41:21 | 显示全部楼层
得出的html里面没有任何数据啊
 楼主| 发表于 2013-7-12 10:44:38 | 显示全部楼层
本帖最后由 wxfy2011 于 2013-7-12 10:55 编辑
  1.   string dltUrl = "http://caipiao.taobao.com/lottery/order/united_hall.htm?spm=0.0.0.0.DDPcSQ&lottery_type=3D";

  2.             HttpHelper objhttp    =   new HttpHelper();    //参数对象      
  3.             HttpItem  objHttpItem =   new HttpItem()            
  4.             {               
  5.                 URL = dltUrl,                           
  6.                 Method = "GET",           
  7.             };
  8.             HttpResult result = objhttp.GetHtml(objHttpItem);    //取Html        
  9.             string html = result.Html;

  10.             string tb_token = result.Cookie.Substring(result.Cookie.IndexOf("HttpOnly,_t")+20);
  11.             string[] tb_token_array = tb_token.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

  12.             dltUrl = "http://caipiao.taobao.com/lottery/order/united_hall.htm?_tb_token_=" + tb_token_array[0] + "&page=2&lottery_type=3D&sort_obj=process&sort=desc&change_sort=&lowAmount=&highAmount=&play_type=0&issue=2013185&status=1&amountSec=0-0&commissionRate=-1&creator=";
  13.             objHttpItem = new HttpItem()                   //参数对象
  14.             {
  15.                 URL = dltUrl,
  16.                 //  Encoding = "gb2312",
  17.                 Method = "GET",
  18.                 Cookie = objHttpItem.Cookie,
  19.             };            //取Html         
  20.             result = objhttp.GetHtml(objHttpItem);
  21.             html = result.Html;

复制代码
下面是我的代码,第一次能到得到数据,下面第二页的就得不到了
 楼主| 发表于 2013-7-12 10:52:26 | 显示全部楼层
站长苏飞 发表于 2013-7-12 10:33
可以呀,直接写代码就行

站长这个代码不行啊,没有任何数据啊
发表于 2013-7-12 10:53:13 | 显示全部楼层
加上来源,Cookie我估计需要格式化,你用我的类格式化一下试试
 楼主| 发表于 2013-7-13 21:06:17 | 显示全部楼层
站长苏飞 发表于 2013-7-12 10:53
加上来源,Cookie我估计需要格式化,你用我的类格式化一下试试

谢谢老大啊,果然厉害成功啦
发表于 2013-7-13 21:54:05 | 显示全部楼层
膜拜中……
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-2 07:45

© 2014-2021

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