.通过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();
}

 

相关文章:

  • 2021-07-21
  • 2022-01-18
  • 2021-11-19
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
猜你喜欢
  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
  • 2022-02-21
相关资源
相似解决方案