2 yy520a yy520a 于 2016.03.05 14:43 提问

Http协议 get请求页面,返回的为什么是未经过解析的代码? 100C

get操作

为什么返回的是这个未经过解析的结果?

 <html>
<head>
<META NAME="robots" CONTENT="noindex,nofollow">
<script>
(function() {  function getSessionCookies() {   cookieArray = new Array();   var cName = /^\s?incap_ses_/;   var c = 

document.cookie.split(";");   for (var i = 0; i < c.length; i++) {    key = c[i].substr(0, c[i].indexOf("="));    value = c[i].substr

(c[i].indexOf("=") + 1, c[i].length);    if (cName.test(key)) {     cookieArray[cookieArray.length] = value    }   }   return 

cookieArray  }  function setIncapCookie(vArray) {   try {    cookies = getSessionCookies();    digests = new Array(cookies.length);    

for (var i = 0; i < cookies.length; i++) {     digests[i] = simpleDigest((vArray) + cookies[i])    }    res = vArray + ",digest=" + 

(digests.join())   } catch (e) {    res = vArray + ",digest=" + (encodeURIComponent(e.toString()))   }   createCookie("___utmvc", res, 

20)  }  function simpleDigest(mystr) {   var res = 0;   for (var i = 0; i < mystr.length; i++) {    res += mystr.charCodeAt(i)   }   

return res  }  function createCookie(name, value, seconds) {   if (seconds) {    var date = new Date();    date.setTime(date.getTime() 

+ (seconds * 1000));    var expires = "; expires=" + date.toGMTString()   } else {    var expires = ""   }   document.cookie = name + 

"=" + value + expires + "; path=/"  }  function test(o) {   var res = "";   var vArray = new Array();   for (var j = 0; j < o.length; 

j++) {    var test = o[j][0]    switch (o[j][1]) {    case "exists":     try {   if(typeof(eval(test)) != "undefined"){         

vArray[vArray.length] = encodeURIComponent(test + "=true")   }   else{      vArray[vArray.length] = encodeURIComponent

(test + "=false")    }     } catch (e) {      vArray[vArray.length] = encodeURIComponent(test + "=false")     }     break;    case 

"value":     try {      vArray[vArray.length] = encodeURIComponent(test + "=" + eval(test).toString())     } catch (e) {      vArray

[vArray.length] = encodeURIComponent(test + "=" + e)     }     break;   case "value_or_nil":        try{            if

(typeof(eval(test)) != "undefined"){                vArray[vArray.length] = encodeURIComponent(test + "=" + eval

(test).toString())          }           else{               vArray[vArray.length] = 

encodeURIComponent(test + "=nil")           }                   }       catch(e){       

    vArray[vArray.length] = encodeURIComponent(test + ":" + test_type + "=" + e)        }       break;     case 

"plugin_extentions":        try {           extentions = []             for (var 

i=0;i<navigator.plugins.length;i++) {               filename = navigator.plugins[i].filename                

if(typeof(filename) != "undefined") {                   if (filename.split(".").length == 2) {              

        ext = filename.split(".")[1]                        if (extentions.indexOf(ext) < 0) {      

                    extentions.push(ext)                        }               

                    }               }               }           for (i = 

0; i < extentions.length; i++) {                vArray[vArray.length] = encodeURIComponent("plugin_ext=" + extentions

[i]);           }       } catch (e) {        vArray[vArray.length] = encodeURIComponent("plugin_ext=" + e)      

}       break;  case "plugins":     try{         p=navigator.plugins         pres=""         for (a in p){pres+=(p[a]

['description']+" ").substring(0,20)}         vArray[vArray.length] = encodeURIComponent("plugins=" + pres);         }     catch(e){   

      vArray[vArray.length] = encodeURIComponent("plugins=" +e);         }  break;      case "plugin":     try {      a = 

navigator.plugins;      for (i in a) {       f = a[i]["filename"].split(".");       if (f.length == 2) {        vArray[vArray.length] 

= encodeURIComponent("plugin=" + f[1]);        break       }      }     } catch (e) {      vArray[vArray.length] = encodeURIComponent

("plugin=" + e)     }     break    }   }   vArray = vArray.join();   return vArray  }  var o = [   ["navigator", "exists"],   

["navigator.vendor", "value"],   ["navigator.vendor", "value_or_nil"],   ["opera", "exists"],   ["ActiveXObject", "exists"],   

["navigator.appName", "value"],   ["navigator.appName", "value_or_nil"],   ["platform", "plugin"],   ["platform", 

"plugin_extentions"],   ["webkitURL", "exists"],   ["navigator.plugins.length==0", "value"],   ["navigator.plugins.length==0", 

"value_or_nil"],   ["_phantom", "exists"] ];  try {   setIncapCookie(test(o));   document.createElement("img").src = 

"/_Incapsula_Resource?SWKMTFSR=1&e=" + Math.random()  } catch (e) {   img = document.createElement("img");   img.src = 

"/_Incapsula_Resource?SWKMTFSR=1&e=" + e  } })();
</script>
<script>
(function() { 
var z="";var 

b="7472797B766172207868723B76617220743D6E6577204461746528292E67657454696D6528293B766172207374617475733D227374617274223B7661722074696D6

96E673D6E65772041727261792833293B77696E646F772E6F6E756E6C6F61643D66756E6374696F6E28297B74696D696E675B325D3D22723A222B286E6577204461746

528292E67657454696D6528292D74293B646F63756D656E742E637265617465456C656D656E742822696D6722292E7372633D222F5F496E63617073756C615F5265736

F757263653F4553324C555243543D363726743D373826643D222B656E636F6465555249436F6D706F6E656E74287374617475732B222028222B74696D696E672E6A6F6

96E28292B222922297D3B69662877696E646F772E584D4C4874747052657175657374297B7868723D6E657720584D4C48747470526571756573747D656C73657B78687

23D6E657720416374697665584F626A65637428224D6963726F736F66742E584D4C4854545022297D7868722E6F6E726561647973746174656368616E67653D66756E6

374696F6E28297B737769746368287868722E72656164795374617465297B6361736520303A7374617475733D6E6577204461746528292E67657454696D6528292D742

B223A2072657175657374206E6F7420696E697469616C697A656420223B627265616B3B6361736520313A7374617475733D6E6577204461746528292E67657454696D6

528292D742B223A2073657276657220636F6E6E656374696F6E2065737461626C6973686564223B627265616B3B6361736520323A7374617475733D6E6577204461746

528292E67657454696D6528292D742B223A2072657175657374207265636569766564223B627265616B3B6361736520333A7374617475733D6E6577204461746528292

E67657454696D6528292D742B223A2070726F63657373696E672072657175657374223B627265616B3B6361736520343A7374617475733D22636F6D706C657465223B7

4696D696E675B315D3D22633A222B286E6577204461746528292E67657454696D6528292D74293B6966287868722E7374617475733D3D323030297B706172656E742E6

C6F636174696F6E2E72656C6F616428297D627265616B7D7D3B74696D696E675B305D3D22733A222B286E6577204461746528292E67657454696D6528292D74293B786

8722E6F70656E2822474554222C222F5F496E63617073756C615F5265736F757263653F535748414E45444C3D323032323435333335373832393938393330312C34343

9343735343238383537333032323038302C31333934313435363332383536343334363138322C313432323937222C66616C7365293B7868722E73656E64286E756C6C2

97D63617463682863297B7374617475732B3D6E6577204461746528292E67657454696D6528292D742B2220696E6361705F6578633A20222B633B646F63756D656E742

E637265617465456C656D656E742822696D6722292E7372633D222F5F496E63617073756C615F5265736F757263653F4553324C555243543D363726743D373826643D2

22B656E636F6465555249436F6D706F6E656E74287374617475732B222028222B74696D696E672E6A6F696E28292B222922297D3B";for (var i=0;i<b.length;i

+=2){z=z+parseInt(b.substring(i, i+2), 16)+",";}z = z.substring(0,z.length-1); eval(eval('String.fromCharCode('+z+')'));})();
</script></head>
<body>
<iframe style="display:none;visibility:hidden;" src="//content.incapsula.com/jsTest.html" id="gaIframe"></iframe>
</body></html>

而浏览器返回的结果是正常的
正确的返回结果

那么请问,这个到底是什么原因呢?
怎么才能用 get方式 正确获取到 这个结果?

8个回答

showbo
showbo   Ds   Rxr 2016.03.05 19:33

服务器端得xhr请求得到的就是浏览器打开后查看源代码弹出的内容一模一样,js脚本之类动态生成的内容获取不到,你要获取js动态生成的内容,自己找下数据接口,ajax从哪个地址请求的,然后捉取哪个接口页面

Marksinoberg
Marksinoberg   Ds   Rxr 2016.03.06 07:45

你好,这个问题的原因是程序返回的结果就是一个html文件,所以是原始数据。而使用浏览器打开,浏览器会自动的帮你解析,所以你就会看到具体的内容。希望能帮到你哈图片说明

qq_20039385
qq_20039385   2016.03.05 22:50

返回值就是html内容,就好比调用支付宝的支付接口,返回的就是html

yale8848
yale8848   2016.03.06 16:02

浏览器收到页面内容后要进行页面内容渲染,过程很复杂,但是其中有一项就是要执行js,而js可以修改原始的内容数据和展现形式,所以你看到的界面就和原始数据不太一样,其实你看到变化的界面的内容是可以从js代码里找到,你可以通过C#正则表达式从内容解析到自己想要的数据,你可以试试!

qq_16414307
qq_16414307   2016.03.06 16:15

一个GET请求,只会返回一个文件,html文件来说,就是一个文本文件.

页面中css,图片,都是浏览器额外抓取其他内容或者执行js生成出来的.

如果你希望是返回一个可视的 图片 , 你可以找其他软件,模拟浏览器,返回一个渲染好的图片

dongfeng9ge
dongfeng9ge   Ds   Rxr 2016.03.05 16:27

应该是后台的问题和你这边无关

WinsenJiansbomber
WinsenJiansbomber   2016.03.05 15:49

看你这个问题问得,get本来就是取服务器上的文件,它才不管服务器给它什么东西呢。你给什么地址,它就到什么地方取文件,即使用里面有JS代码,它也不会执行的啊。

要看到页面是什么样子,只有通过浏览器解析里面的内容才可以了。

oyljerry
oyljerry   Ds   Rxr 2016.03.05 16:04

这个返回的就是html页面内容,只不过浏览器有DOM引擎替你解析了,作为程序就需要自己来解析

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!