|
我的代码:
string strResult = "";
try
{
CookieContainer cookie = new CookieContainer();
HttpWebRequest http = (HttpWebRequest)WebRequest.Create(url);
http.AllowAutoRedirect = false ;
http.KeepAlive = true;
http.Method = "POST";
http.Timeout = 5000;
http.CookieContainer = cookie;
HttpWebResponse response = (HttpWebResponse)http.GetResponse();
Stream streamReceive = response.GetResponseStream();
StreamReader streamReader = new StreamReader(streamReceive, Encoding .UTF8 );
strResult = streamReader.ReadToEnd();
streamReader.Close();
streamReceive.Close();
response.Close();
http.Abort();
return strResult;
}
catch{
...}
为什么我在访问“http://www.ria.ru/”网站的时候,得到的是
“<!DOCTYPE html SYSTEM "about:legacy-compat">
<html lang="ru"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script src="/js/libs/jquery.min.js?"></script><script src="/js/libs/swfobject.js?"></script><script>var redirecturl = ''; var senddata = '{ "flash_support": ' + (swfobject.getFlashPlayerVersion().major > 0 ? 1 : 0) + ' }'; $.ajax({ type: 'POST', url: '/services/js_store', data: {action: "save", data: senddata}, success: function(data) { if (data.status == "OK") { if (redirecturl != '') { location.href = redirecturl; } else { location.reload(); } } }, dataType: "json" });</script><meta http-equiv="refresh" content="2;url=/"><noscript><meta http-equiv="refresh" content="0;url=/"></noscript></head><body></body></html>
”
而不是网页内容 |
|