/// <summary>
/// 获取远程文件HTML
/// </summary>
/// <param name="URL"></param>
/// <returns></returns>
public static String RemoteHtml(String URL)
{
try
{
WebRequest bi
= WebRequest.Create(URL);
WebResponse gbi
= bi.GetResponse();
//此时接收到的为数据流,所以需要一个streamreader来进行读取,并且在读取时设置编码格式,一般情况下设置为默认即可..
//使用streamreader需要添加引用using System.IO;
StreamReader rbi = new StreamReader(gbi.GetResponseStream(), System.Text.Encoding.Default);
String str
= rbi.ReadToEnd();
return str;
}
catch
{
return "";
}
}

 


把目标的html代码获取到页面上
        }
    }

相关文章:

  • 2021-07-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-08
  • 2022-12-23
  • 2022-01-31
猜你喜欢
  • 2021-07-20
  • 2021-10-05
  • 2022-01-04
  • 2021-11-30
  • 2022-12-23
  • 2021-08-05
  • 2021-06-22
相关资源
相似解决方案