一.通过javascript可获取某个网站的HTML,不过只在IE下有效
function getHTTPPage(jnkcUrl) { var objxml = new ActiveXObject("Microsoft.XMLHTTP"); objxml.open("GET", jnkcUrl, false); objxml.send(); var sResult = objxml.responseText; return sResult; }
二.通过C#获取
/// <summary> /// 获取网页内容 /// </summary> /// <param name="url">网址</param> /// <returns>网站内容</returns> public string GetWebSiteContent(string url) { System.Net.WebClient web = new System.Net.WebClient(); System.IO.Stream stream = web.OpenRead(url); System.IO.StreamReader sr = new System.IO.StreamReader(stream, System.Text.Encoding.Default); return sr.ReadToEnd(); }