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

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

查看: 6670|回复: 3

[HttpHelper] 调用的时候和测试的时候返回html不一样

[复制链接]
发表于 2015-5-4 11:12:53 | 显示全部楼层 |阅读模式
1金钱
本帖最后由 zyf7758521ai 于 2015-5-4 11:15 编辑

  • view plainprint?

    • HttpHelper http = new HttpHelper();
    • HttpItem item = new HttpItem()
    • {
    •     URL = "https://portal.shop.letv.com/order/api/web/insert/fastBuyRushOrder.jsonp?fast_address_id=2487854&order_way=0&rush_id=779&productid_promotionid_quantityingroup_quantity=600200001624_GWGT502014_1_1^206400000400_GWGT502014_2",//URL     必需项
    •     Method = "GET",//URL     可选项 默认为Get
    •     Timeout = 100000,//连接超时时间     可选项默认为100000
    •     ReadWriteTimeout = 30000,//写入Post数据超时时间     可选项默认为30000
    •     IsToLower = false,//得到的HTML代码是否转成小写     可选项默认转小写
    •     Cookie = "COOKIE_THIRDPARTY_ID=84133704;COOKIE_TOKEN_ID_N=b7f51263a13cbbe5c69cc59d170223c2;COOKIE_USER_IP=222.132.223.8;COOKIE_USER_NAME=4cb78235cc6e61a53d3bdb19d05a60cd;COOKIE_NICKNAME=user84133704;COOKIE_USER_LEVEL_ID=1;COOKIE_SESSION_ID=DD47EEB3E2C4A60186ECEDC72CF40067;COOKIE_TOKEN_ID=cf4aab66cd0e26e474de6eb2ebbcff49;COOKIE_TOKEN_DATE=1430706544825;COOKIE_USER_ID=284133704;COOKIE_USER_TYPE=1;COOKIE_LOGIN_TYPE=5;COOKIE_USER_INFO=user84133704%5E824100841%40163.com%5E%5E84133704%5Ehttp%3A%2F%2Fi1.letvimg.com%2Fimg%2F201207%2F30%2Ftx298.png%2Chttp%3A%2F%2Fi0.letvimg.com%2Fimg%2F201207%2F30%2Ftx200.png%2Chttp%3A%2F%2Fi0.letvimg.com%2Fimg%2F201207%2F30%2Ftx70.png%2Chttp%3A%2F%2Fi3.letvimg.com%2Fimg%2F201207%2F30%2Ftx50.png%5E;COOKIE_S_TOKEN_ID=8e47a60823ae2a00e683509bf7102743;COOKIE_S_TOKEN_ID_N=abeb4db6c5308ef8c34b18a3576db7d6;",//字符串Cookie     可选项
    •     UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0",//用户的浏览器类型,版本,操作系统     可选项有默认值
    •     Accept = "text/html, application/xhtml+xml, */*",//    可选项有默认值
    •     ContentType = "application/x-www-form-urlencoded",//返回类型    可选项有默认值
    •     Referer ="http://shop.letv.com/huodong/150505.html",//来源URL     可选项
    •     Allowautoredirect = False,//是否根据301跳转     可选项
    •     //CerPath = "d:\123.cer",//证书绝对路径     可选项不需要证书时可以不写这个参数
    •     //Connectionlimit = 1024,//最大连接数     可选项 默认为1024
    •     Postdata = "",//Post数据     可选项GET时不需要写
    •     //ProxyIp = "192.168.1.105:2020",//代理服务器ID     可选项 不需要代理 时可以不设置这三个参数
    •     //ProxyPwd = "123456",//代理服务器密码     可选项
    •     //ProxyUserName = "administrator",//代理服务器账户名     可选项
    •     ResultType = ResultType.String,//返回数据类型,是Byte还是String
    • };
    • HttpResult result = http.GetHtml(item);
    • string html = result.Html;

  • null({"message":"rushNotStart","result":"rushNotStart","status":"8"});  








以上是测试返回结果
       HttpHelper Http = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = string.Format(@"https://portal.shop.letv.com/order/api/web/insert/fastBuyRushOrder.jsonp?fast_address_id={0}&order_way=0&rush_id={1}&productid_promotionid_quantityingroup_quantity={2}", addressid, rushId, productid),
                Method = "GET",
                ContentType = "application/x-www-form-urlencoded",//返回类型    可选项有默认值
                Referer = MyList.huodongUrl,
                Cookie = Cookies
            };
            HttpResult result = Http.GetHtml(item);
            result = Http.GetHtml(item);
            string html = result.Html;


<html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body bgcolor="white">
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>nginx</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->


用的时候返回的结果





1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2015-5-4 11:19:32 | 显示全部楼层
Cookie失效了吧
回复

使用道具 举报

 楼主| 发表于 2015-5-4 11:21:18 | 显示全部楼层

Cookie没有失效,现在也可以用的
回复

使用道具 举报

发表于 2015-5-4 13:58:02 | 显示全部楼层
用我的在线直接生成 的代码不行吗?
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-18 14:31

© 2014-2021

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