Asp.net 获取网页源代码
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
///获取页面源代码
////summary
///paramname="url"/param
///returns/returns
publicstaticstringGetPageResouceCode(stringurl)
{
try
{
WebRequestwrt=WebRequest.Create(url);
WebResponsewrse=wrt.GetResponse();
StreamstrM=wrse.GetResponseStream();
StreamReaderSR=newStreamReader(strM,Encoding.UTF8);
stringstrallstrm=SR.ReadToEnd();
returnstrallstrm;
}
catch{
return"";
}
}