我正在使用下面给出的代码下载网页内容。
using (var w = new System.Net.WebClient())
{
w.Encoding = System.Text.Encoding.UTF8;
w.Headers["User-Agent"] = "Mozilla / 5.0(Windows NT 6.3; Win64; x64) AppleWebKit / 537.36(KHTML, like Gecko) Chrome / 59.0.3071.104 Safari / 537.36";
var HtmlMarkup = w.DownloadString("http://www.as.com/statistics/announcements.do?by=asxCode&asxCode=HLO&timeframe=Y&year=" + i);
}
我得到的回复没有任何内容。但是当我浏览页面时,数据加载正常。
调用的返回字符串是
<html><head>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="-1"/>
<meta http-equiv="CacheControl" content="no-cache"/>
<noscript>Please enable JavaScript to view the page content.</noscript>
<APM_DO_NOT_TOUCH>
<script language="javascript">
(function(){
var securemsg;
var packmsg;
var CryptoUtils;
try{(function(){try{var IS,lS,oS=1;for(var OS=0;OS<lS;++OS)oS+=3;IS=oS;window._===IS&&(window._=++IS)}catch(ZS){window._=IS}var __=window.sdkljshr489=!0;function i_(S){window.sdkljshr489&&S&&(__=!1);return __}function I_(){}i_(window[I_.name]===I_);i_("undefined"===window.vodsS0);window.vodsS0=null;i_(/\x3c/.test(function(){return"\x3c"})&/x3d/.test(function(){return"0";"x3d"}));var j_=/mobi/i.test(navigator.userAgent),L_=+new Date,o_=j_?3E4:3E3;
function O_(){return i_(L_+o_<(L_=+new Date))}(function(){var S={decrypt:function(S){try{return JSON.parse(function(S){S=S.split("l");var l="";for(var L=0;L<S.length;++L)l+=String.fromCharCode(S[L]);return l}(S))}catch(L){}}};return S={configuration:S.decrypt("123l34l97l99l116l105l118l101l34l58l34l110l111l34l44l34l100l101l98l117l103l103l105l110l103l34l58l34l110l111l34l44l34l109l111l100l117l108l101l49l34l58l34l101l110l97l98l108l101l100l34l44l34l109l111l100l117l108l101l50l34l58l34l101l110l97l98l108l101l100l34l44l34l109l111l100l117l108l101l51l34l58l34l101l110l97l98l108l101l100l34l44l34l109l111l100l117l108l101l52l34l58l34l101l110l97l98l108l101l100l34l125")}})();
window.oi={iI:"083bf9465983600168c93c2ae5d6089fc80f5d9cdecbe2a72745978b659d0db65c4b160ead8f315f1f237ad9f9e564d01d83dbf26889df1ede7f7ba955e6bab40420777eb33ed8d840f8207497eeae34352c7f61b72dd3de0308c8204b76b26a1b5dedd0a9b46bd6bca06659f4d4c367377b67edc9476b4400fc730bc63f181a706e1d4d04de8c0da9afb8899a74c51a4af04334e56f4bff5289a8f3db5b9d808dbf78d462b235fec02458e1c8789fca6957d4f785fec9ce95c4fe9f1aea873b5d40fd674ea3dc163ef159103f8d9bcde332469779265b0dd6b46081b36242006127c3b11039ebdf99311e775d35afb12dfde4131734b06948fe09f10dc119524a962a179d4ea3f904d2273257a0bcb5a071c77d58556abf82c6142043e28222d1509fbd0d77a8758baeb6150cd731fc70fa2fb20bd5ce7f65f30c3cf6a71a35b5e00481a995235137b79b4ee773bc1ff94e8f45930fb36c274282a05dc3664218d67bc8b5fcad3a"};function I(S){return 231>S}function J(){var S=arguments.length,l=[];for(var L=0;L<S;++L)l.push(arguments[L]-64);return String.fromCharCode.apply(String,l)}function z(S){return S.toString(36)}(function z_(l){l&&"number"!==typeof l||("number"!==typeof l&&(l=1E3),l=Math.max(l,1),setInterval(function(){z_(l-10)},l))})(O_());var n;})();}finally{sdkljshr489=false;ie9rgb4=void(0);};
eval((ie9rgb4=function (){var m='function () {/*fQb f_TcC}-di`U_V YU)bWR$+dbikuVe^SdY_^uvkdbikfQb 9Cy\\Cy_C-!yJO-!ycO-!yCY-!yOY-!yYY-!y9Y-!yZY-!+V_bufQb ?C-}+?C,\\C+xx?Cv_Cx-"yJOx-"ycOx-"yCYx-"yOYx-"yYYx-"y9Yx-"yZYx-#+9C-_CxJOxcOxCYxOYxYYx9YxZY+gY^T_g{O---9CssugY^T_g{O-xx9CvmSQdSXuJCvkgY^T_g{O-9CmfQb OO-gY^T_g{cT[\\ZcXb$()-n}+Ve^SdY_^ YOuCvkgY^T_g{cT[\\ZcXb$()ssCssu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(vy}v+<,CKju!")$#))"}%vM+xx<v\\-
答案 0 :(得分:1)
似乎使用Javascript加载实际网页。尝试使用C#的WebBrowser浏览网页,然后从那里获得响应,请参阅RăzvanPanda的Answer
答案 1 :(得分:0)
许多页面会在标题中查找内容,以确保您不会抓取页面,这可能会发生在这里。
最好的方法是下载Fiddler免费。关闭所有互联网浏览器并运行它然后在浏览器中浏览页面并记录传递的所有数据。然后,您可以暂停它并检查发送的内容并复制它。
还可以使用插件Request to Code来创建C#代码以匹配您的请求,然后只需粘贴到您的代码中或根据需要进行修改。
这是我发现的最简单方法。只需浏览网站并单击即可获取源代码,并在不到一分钟的时间内获得正常工作的代码。