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

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

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

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

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

查看: 14592|回复: 15

[其他] C#post提交到dwr页面返回数据错误

[复制链接]
发表于 2013-1-28 10:16:02 | 显示全部楼层 |阅读模式
C#post提交到dwr页面返回数据错误,抓包的信息是通过ie的插件抓的,在软件中模拟,返回的数据是
//#DWR-REPLY
if (window.dwr) dwr.engine._remoteHandleBatchException({ name:'java.lang.SecurityException', message:'Batch IDs may only contain Java Identifiers' });
else if (window.parent.dwr) window.parent.dwr.engine._remoteHandleBatchException({ name:'java.lang.SecurityException', message:'Batch IDs may only contain Java Identifiers' });
这个是第一个问题,

然后换另一个软件测试,返回了登陆前的页面代码,与原ie提交相同的页面返回数据不同

第三个问题就是,提交的数据,只有ie第一次可以获得数据,删除抓包信息,刷新页面,这时候查看不到抓包信息,这是怎么回事?


1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2013-1-28 10:24:20 | 显示全部楼层
1.没有代码和网址无法知道具体情况,所以请发上来你的代码看看
2.IE得到的是执行过JS和运算之后的页面,HttpHelper是获取的源代码是肯定不一样的,
3.那上IE缓存问题,
 楼主| 发表于 2013-1-28 10:36:51 | 显示全部楼层
admin 发表于 2013-1-28 10:24
1.没有代码和网址无法知道具体情况,所以请发上来你的代码看看
2.IE得到的是执行过JS和运算之后的页面,Ht ...

post头及数据
  1. POST /dwr/call/plaincall/IdxMgr.getShifenBalanceInfo.dwr HTTP/1.1
  2. Accept: */*
  3. Accept-Language: zh-cn
  4. Referer: http://fengchao.baidu.com/indexAction.do?uid=【个人id,人为替换下,是7位数字】&userid=【个人id,人为替换下,是7位数字】
  5. Content-Type: text/plain
  6. Accept-Encoding: gzip, deflate
  7. User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
  8. Host: fengchao.baidu.com
  9. Content-Length: 283
  10. Connection: Keep-Alive
  11. Cache-Control: no-cache
  12. Cookie: SFSSID=65e60e0e5c7b1795a5984aa00bb8c126; SIGNIN_UC=70a2711cf1d3d9b1a82d2f87d633bd8a01093465777; H_PS_PSSID=1456; BAIDUID=23118C90F669B92230AD7CEB298E42BC:FG=1; __cas__st__3=1851e52a3aff8dcbbb32235442cb0b888ba30f2e092883e369bfe96ec7bddc764395b2e10f3004dc5859ea78; __cas__id__3=【个人id,人为替换下,是7位数字】; __cas__rn__=109346577; SAMPLING_USER_ID=【个人id,人为替换下,是7位数字】; JSESSIONID=EA8E3F07BB7BA9AEFCB3440E52824003

  13. callCount=1
  14. page=/indexAction.do?uid=【个人id,人为替换下,是7位数字】&userid=【个人id,人为替换下,是7位数字】
  15. httpSessionId=EA8E3F07BB7BA9AEFCB3440E52824003
  16. scriptSessionId=E5930CC6055F50622E5843F0A9431126437
  17. c0-scriptName=IdxMgr
  18. c0-methodName=getShifenBalanceInfo
  19. c0-id=0
  20. c0-param0=number:【个人id,人为替换下,是7位数字】
  21. c0-param1=number:【个人id,人为替换下,是7位数字】
  22. batchId=1
复制代码
使用httphelper得到的数据:
  1. //#DWR-REPLY
  2. if (window.dwr) dwr.engine._remoteHandleBatchException({ name:'java.lang.SecurityException', message:'Batch IDs may only contain Java Identifiers' });
  3. else if (window.parent.dwr) window.parent.dwr.engine._remoteHandleBatchException({ name:'java.lang.SecurityException', message:'Batch IDs may only contain Java Identifiers' });
复制代码
使用其他post测试软件得到的数据
  1. 第1次请求 POST
  2. 地址:http://fengchao.baidu.com/dwr/call/plaincall/IdxMgr.getShifenBalanceInfo.dwr
  3. 状态:302
  4. ===================================
  5. HTTP/1.1 302 Moved Temporarily
  6. Server: Apache-Coyote/1.1
  7. Set-Cookie: __cas__st__3=null; Expires=Thu, 01-Jan-1970 00:00:10 GMT
  8. Set-Cookie: __cas__st__3=null; Expires=Thu, 01-Jan-1970 00:00:10 GMT
  9. Set-Cookie: __cas__id__3=null; Expires=Thu, 01-Jan-1970 00:00:10 GMT
  10. Set-Cookie: __cas__id__3=null; Expires=Thu, 01-Jan-1970 00:00:10 GMT
  11. Set-Cookie: __cas__st__3=NLI; Domain=fengchao.baidu.com; Path=/
  12. Set-Cookie: __cas__id__3=0; Domain=fengchao.baidu.com; Path=/
  13. Set-Cookie: __cas__rn__=109346577; Domain=fengchao.baidu.com; Path=/
  14. Location: http://cas.baidu.com/?action=check&appid=3&u=http%3A%2F%2Ffengchao.baidu.com%2Fdwr%2Fcall%2Fplaincall%2FIdxMgr.getShifenBalanceInfo.dwr
  15. Content-Length: 0
  16. Date: Mon, 28 Jan 2013 01:41:41 GMT
  17. Connection: Keep-Alive


  18. ===================================

  19. 第2次请求 GET
  20. 地址:http://cas.baidu.com/?action=check&appid=3&u=http%3A%2F%2Ffengchao.baidu.com%2Fdwr%2Fcall%2Fplaincall%2FIdxMgr.getShifenBalanceInfo.dwr
  21. 状态:302
  22. ===================================

  23. ===================================

  24. 第3次请求 GET
  25. 地址:http://cas.baidu.com/?tpl=www2&fromu=http%3A%2F%2Ffengchao.baidu.com%2Fdwr%2Fcall%2Fplaincall%2FIdxMgr.getShifenBalanceInfo.dwr
  26. 状态:200
  27. ===================================
  28. &#65279;<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  29. <html>
  30. <head>
  31. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  32. <meta http-equiv="pragma" content="no-cache">
  33. <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
  34. <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
  35. <title>百度推广</title>

  36. <script type="text/javascript" charset="UTF-8" src="main.js"></script>
  37. </head>

  38. <body>
  39.     <div id="Banner">
  40.         <div id="BannerWrap"></div>
  41.         <div id="BannerIndex"></div>
  42.         <div id="Login"></div>
  43.               <form id="LoginForm" method="POST" action="https://cas.baidu.com/?action=login">
  44.         <table cellspacing="0" cellpadding="0">
  45.           <tr>
  46.             <td width="55" class="error"> </td>
  47.             <td width="180" class="error"><div id="E" title=""></div></td>
  48.           </tr>
  49.           <tr>
  50.             <td class="label">用户名:</td>
  51.             <td><div class="login-input"><input type="text" name="entered_login" id="UserName" value=""></div></td>
  52.           </tr>
  53.           <tr>
  54.             <td class="error"> </td>
  55.             <td class="error"><span id="ErrorName"></span></td>
  56.           </tr>
  57.           <tr>
  58.             <td class="label">密    码:</td>
  59.             <td><div class="login-input"><input type="password" name="entered_password" id="Password"></div></td>
  60.           </tr>
  61.           <tr>
  62.             <td class="error"> </td>
  63.             <td class="error"><span id="ErrorPsw"></span></td>
  64.           </tr>
  65.           <tr>
  66.             <td class="label">验证码:</td>
  67.             <td>
  68.               <div class="code-input"><input type="text" name="entered_imagecode" maxlength="4" id="Code"></div>
  69.               <span id="Loading">正在加载验证码...</span>
  70.               <img id="CodeImg" style="display:none" src="" onload="showCode(this)">
  71.             </td>
  72.           </tr>
  73.           <tr>
  74.             <td class="error"> </td>
  75.             <td class="error"><span id="ErrorCode"></span></td>
  76.           </tr>
  77.           <tr>
  78.             <td></td>
  79.             <td><a href="#" id="Submit"> </a><a target="_blank" href="http://www2.baidu.com/user/getpwd.php" id="Forget">忘了密码?</a></td>
  80.           </tr>
  81.         </table>
  82.         <input type="hidden" name="charset" value="utf-8">
  83.         <input type="hidden" name="appid" value="3">
  84.         <input type="hidden" name="fromu" value="http%3A%2F%2Ffengchao.baidu.com%2Fdwr%2Fcall%2Fplaincall%2FIdxMgr.getShifenBalanceInfo.dwr">
  85.       </form>
  86.         <div id="question" style="display:none">
  87.       <div class="i_title"><span id="notice">评价百度推广</span><a href="#" id="close"></a></div>
  88.       <div class="i_content i_success" id="successContent">
  89.         <img src="img/success.gif">
  90.         <div style="height:55px;line-height:55px">您的评价已成功提交,感谢您的配合</div>
  91.         <input type="button" id="s_close" value="关闭"/>
  92.       </div>
  93.       
  94.       <div class="i_content" id="questionContent">
  95.         <div class="i_name"><div class="fl">用户名:</div><div class="fl" id="s_uname_wrap"><input id="s_uname" type="text"></input></div><div class="fl" style="color:red;margin-left:10px;font-weight:bold;font-family:Arial, Helvetica, sans-serif;">*</div>
  96.           <div class="clear"></div>
  97.         </div>
  98.         <div class="i_satisfaction">
  99.            <div class="fl">满意度:</div>
  100.            <div class="fl" id="stars">
  101.              <a href="#" onclick="return star(1)" onmouseover="starOver(1)" onmouseout="starOut()"></a>
  102.             <a href="#" onclick="return star(2)" onmouseover="starOver(2)" onmouseout="starOut()"></a>
  103.             <a href="#" onclick="return star(3)" onmouseover="starOver(3)" onmouseout="starOut()"></a>
  104.             <a href="#" onclick="return star(4)" onmouseover="starOver(4)" onmouseout="starOut()"></a>
  105.             <a href="#" onclick="return star(5)" onmouseover="starOver(5)" onmouseout="starOut()"></a>
  106.            </div>
  107.            <div id="score"><font id="score_txt" style="color:red;font-family:Tahoma;font-weight:bold;font-size:16px">3</font>分<span id="score_comment"></span></div>
  108.            <div class="clear"></div>
  109.         </div>
  110.         <div></div>
  111.         <div class="suggest_text">
  112.           <div>意见或建议:<span style="color:#b5b3aa">可输入200个汉字</span></div>
  113.           <textarea id="suggest"></textarea>
  114.         </div>
  115.         <div class="btn_box">
  116.           <input type="button" id="s_submit" value="提交"/>
  117.           <input type="button" id="s_cancel" value="取消"/>
  118.         </div>
  119.       </div>
  120.     </div>
  121.     </div>

  122.     <div id="Topics">
  123.         <div id="LeftBar"><a href="#" id="LeftRoll" style="display:none"> </a><div id="LeftDisable"></div></div>
  124.         <div id="MarqueeWrap"><div id="Marquee"></div></div>
  125.         <div id="RightBar"><a href="#" id="RightRoll" style="display:none"> </a><div id="RightDisable" style="display:none"></div></div>
  126.     </div>
  127.    
  128.     <div id="Products">
  129.         <a href="http://editor.baidu.com" target="_blank" id="Product5"> </a>
  130.         <a href="http://tongji.baidu.com" target="_blank" id="Product1"> </a>
  131.         <a href="http://qiao.baidu.com" target="_blank" id="Product2"> </a>
  132.         <a href="http://yingxiao.baidu.com/support/" target="_blank" id="Product3"> </a>
  133.         <a href="http://wm123.baidu.com" target="_blank" id="Product7"> </a>
  134.         <a href="http://cy.baidu.com" target="_blank" id="Product6"> </a>
  135.      <a href="http://apihome.baidu.com" target="_blank" id="Product4"> </a>
  136.     </div>
  137. </div>
  138. <script type="text/javascript" charset="UTF-8" src="http://yingxiao.baidu.com/support/fc/?action=bigimgInterface&method=Banner.init"></script>
  139. <script type="text/javascript" charset="UTF-8" src="http://yingxiao.baidu.com/support/fc/?action=loginTopicInterface&method=Topic.init"></script>
  140. <script type="text/javascript">
  141. var suggestURL = "http://research.baidu.com/feedback/customerfeedback.php";
  142.   addTime();
  143.   bind();
  144.   G("UserName").select();
  145.   G("UserName").focus();
  146. </script>
  147. <script type="text/javascript">
  148. var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
  149. document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fa3235af8d49a49f7507f4af517bff219' type='text/javascript'%3E%3C/script%3E"));
  150. </script>
  151. </body>
  152. </html> ===================================
复制代码
网页浏览器实际抓包得到的数据
  1. //#DWR-INSERT
  2. //#DWR-REPLY
  3. dwr.engine._remoteHandleCallback('1','0',"["【四位的数字,人为替换掉了】","-1"]");
复制代码
 楼主| 发表于 2013-1-28 10:39:16 | 显示全部楼层
使用其他post测试软件得到的数据 这个栏目,文本太长不允许发,我删掉了一些css代码
发表于 2013-1-28 10:41:40 | 显示全部楼层
这个麻烦了,需要验证Referer 你看一下你的HttpHelper访问的代码吗?
 楼主| 发表于 2013-1-28 10:51:07 | 显示全部楼层
admin 发表于 2013-1-28 10:41
这个麻烦了,需要验证Referer 你看一下你的HttpHelper访问的代码吗?

Referer添加了 确定存在
发表于 2013-1-28 11:02:22 | 显示全部楼层
淘浩哥 发表于 2013-1-28 10:51
Referer添加了 确定存在

我一直没有看到你的HttpHelper代码访问代码,没办法确定问题啊,发一下代码吧
 楼主| 发表于 2013-1-28 11:20:58 | 显示全部楼层
admin 发表于 2013-1-28 11:02
我一直没有看到你的HttpHelper代码访问代码,没办法确定问题啊,发一下代码吧
  1. void Btn_postClick(object sender, EventArgs e)
  2.     {
  3.     HttpHelper http = new HttpHelper();
  4.     HttpItem item = new HttpItem()
  5.     {
  6.       URL = tb_url.Text.Trim(),//URL   必需项
  7.       Encoding = cb_encoding.Text.Trim(),//编码格式(utf-8,gb2312,gbk)   可选项 默认类会自动识别
  8.       Method = cb_action.Text.Trim(),//URL   可选项 默认为Get
  9.       Timeout = Convert.ToInt32(tb_timeout.Text.Trim()),//连接超时时间   可选项默认为100000
  10.       ReadWriteTimeout = Convert.ToInt32(tb_postout.Text.Trim()),//写入Post数据超时时间   可选项默认为30000
  11.       IsToLower = cb_islow.Checked,//得到的HTML代码是否转成小写   可选项默认转小写
  12.       Cookie = tb_cookie.Text.Trim(),//字符串Cookie   可选项
  13.       UserAgent = tb_UserAgent.Text.Trim(),//用户的浏览器类型,版本,操作系统   可选项有默认值
  14.       Accept = tb_accept.Text.Trim(),// "text/html, application/xhtml+xml, */*"   可选项有默认值
  15.       ContentType = tb_ContentType.Text.Trim(),//返回类型  可选项有默认值
  16.       Referer = tb_Referer.Text.Trim(),//来源URL   可选项
  17.       //Allowautoredirect = true,//是否根据301跳转   可选项
  18.       //CerPath = "d:\\123.cer",//证书绝对路径   可选项不需要证书时可以不写这个参数
  19.       //Connectionlimit = 1024,//最大连接数   可选项 默认为1024
  20.       Postdata = tb_postdata.Text.Trim(),//Post数据   可选项GET时不需要写
  21.       ProxyIp = tb_dailiip.Text.Trim(),//代理服务器ID   可选项 不需要代理 时可以不设置这三个参数
  22.       ProxyPwd = tb_dailipwd.Text.Trim(),//代理服务器密码   可选项
  23.       ProxyUserName = tb_dailizccount.Text.Trim(),//代理服务器账户名   可选项
  24.          ResultType = ResultType.Byte,//返回数据类型,是Byte还是String

  25.     };
  26.     tb_returnhtml.Text = http.GetHtml(item);
  27.     tb_allcookie.Text = item.Cookie;
  28.    
  29.     }
复制代码
 楼主| 发表于 2013-1-28 11:23:31 | 显示全部楼层
附件为界面截图
QQ截图20130128112258.png
 楼主| 发表于 2013-1-28 11:24:59 | 显示全部楼层
admin 发表于 2013-1-28 11:02
我一直没有看到你的HttpHelper代码访问代码,没办法确定问题啊,发一下代码吧

我感觉不是httphekper代码的问题 ,post的是dwr的网页,不懂,查看文档,感觉是它的问题
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

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

GMT+8, 2024-4-18 08:44

© 2014-2021

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