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

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

查看: 4352|回复: 12

[HttpHelper] 飞哥 遇到你HttpHelper不能正确解析的问题了

[复制链接]
发表于 2016-8-3 17:21:59 | 显示全部楼层 |阅读模式
飞哥,这是个某APP的数据包,如附件用HttpAnalyzer抓的包,抓包工具也看不到 返回内容是什么用HttpHelper 也无法读取,但是如图,直接用HttpAnalyzer的Http Request Builder 工具模拟这个发包,可以得到正确解析返回内容? 实在是困惑,麻烦飞哥解惑啊~~ QQ图片20160803172130.png

Http.rar

1.84 KB, 下载次数: 29, 下载积分: 金钱 -1



1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2016-8-3 17:57:26 | 显示全部楼层
怎么写的代码贴出来看看
 楼主| 发表于 2016-8-3 21:48:35 | 显示全部楼层
本帖最后由 woshiklc 于 2016-8-3 21:54 编辑
站长苏飞 发表于 2016-8-3 17:57
怎么写的代码贴出来看看

代码如下:
[C#] 纯文本查看 复制代码
HttpHelper Helper = new HttpHelper();
            HttpItem Item = new HttpItem
            {
                URL = "http://appintf.youthlighting.cn:9878/dx-interface-app/v1/sys/version",
                ContentType = "application/json;charset=UTF-8",
                UserAgent="okhttp/3.2.0",                Method="POST",
                Postdata="{\"type\":\"2\",\"secr\":\"39823bd993c4b3390c2217a95b253d35\",\"uuid\":\"00ce46de-f56d-4c21-93d1-09a6570b440f\",\"code\":\"116\"}"
            };
            HttpResult Result = Helper.GetHtml(Item);
            string HtmlContent = Result.Html;
麻烦飞哥看下,谢谢~



发表于 2016-8-4 10:35:15 | 显示全部楼层
这应该是编码问题,换个编码试试
 楼主| 发表于 2016-8-4 10:44:30 | 显示全部楼层
我对照编码表  中文的 基本上 试了一遍了
 楼主| 发表于 2016-8-4 10:55:01 | 显示全部楼层
使用这篇文章里面的编码又跑了个循环,仍然不行
编码格式地址:http://blog.csdn.net/codeeer/article/details/8922505
代码如下:
[C#] 纯文本查看 复制代码
      HttpHelper Helper = new HttpHelper();
            HttpItem Item = new HttpItem
            {
                URL = "http://appintf.youthlighting.cn:9878/dx-interface-app/v2/user/login",
                ContentType = "application/json;charset=UTF-8",
                UserAgent="okhttp/3.2.0",
                Method="POST",
                ResultType = ResultType.Byte,
                Postdata="{\"os\":\"4.4.4\",\"unique_code\":\"864595029439340\",\"secr\":\"d3bbac2be8c3ad95297a3d1dda5ae3bb\",\"unique_type\":\"IMEI\",\"uuid\":\"00ce46de-f56d-4c21-93d1-09a6570b440f\",\"loginid\":\"18352513533\",\"phone_brand\":\"MI 3Xiaomi\",\"app_os\":\"116\",\"password\":\"53efa85c13954b205dae3334b65b81fb\"}"
            };
            HttpResult Result = Helper.GetHtml(Item);
            string[] Encodings = KillTool.ReadFile("编码.txt").Split('\n');
            string HtmlContent = string.Empty;
            foreach (string ee in Encodings)
            {
                HtmlContent = Encoding.GetEncoding(ee.Replace("\r","")).GetString(Result.ResultByte);
                if (HtmlContent.Contains("rtnmsg"))
                    HtmlContent = string.Empty;
            }
发表于 2016-8-4 11:11:51 | 显示全部楼层
取出来再设置编码还有什么用呢?我不是有参数专门修改编码的吗
 楼主| 发表于 2016-8-4 11:19:09 | 显示全部楼层
站长苏飞 发表于 2016-8-4 11:11
取出来再设置编码还有什么用呢?我不是有参数专门修改编码的吗

麻烦您再看下,不知这样写对不对,这样写 仍然无效
[C#] 纯文本查看 复制代码
  HttpHelper Helper = new HttpHelper();
            string[] Encodings = KillTool.ReadFile("编码.txt").Split('\n');
            foreach (string ee in Encodings)
            {
                HttpItem Item = new HttpItem
                {
                    URL = "http://appintf.youthlighting.cn:9878/dx-interface-app/v1/sys/version",
                    ContentType = "application/json;charset=UTF-8",
                    UserAgent="okhttp/3.2.0",
                    Method="POST",
                   // ResultType = ResultType.Byte,
                    Postdata="{\"os\":\"4.4.4\",\"unique_code\":\"864595029439340\",\"secr\":\"d3bbac2be8c3ad95297a3d1dda5ae3bb\",\"unique_type\":\"IMEI\",\"uuid\":\"00ce46de-f56d-4c21-93d1-09a6570b440f\",\"loginid\":\"18352513533\",\"phone_brand\":\"MI 3Xiaomi\",\"app_os\":\"116\",\"password\":\"53efa85c13954b205dae3334b65b81fb\"}",
                    Encoding = Encoding.GetEncoding(ee.Replace("\r", ""))

                };
                HttpResult Result = Helper.GetHtml(Item);
                KillTool.WriteText("Result", Result.Html);
            }
 楼主| 发表于 2016-8-4 16:07:24 | 显示全部楼层
解决了,这个返回头没有提示是GZIP压缩,但是 实际上是GZIP压缩的,飞哥 你的httphelper默认 是没解压缩的,所以说乱码~
发表于 2016-8-4 16:31:29 | 显示全部楼层
woshiklc 发表于 2016-8-4 16:07
解决了,这个返回头没有提示是GZIP压缩,但是 实际上是GZIP压缩的,飞哥 你的httphelper默认 是没解压缩的 ...

哦哦好吧,你加的什么参数,是直接修改的我的代码吗?
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

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

GMT+8, 2024-6-17 12:59

© 2014-2021

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