Copy codeThe Code is as follows:
Public static string GetSourceTextByUrl (string url)
{
WebRequest request = WebRequest. Create (url );
Request. Timeout = 200000; // Timeout in 20 seconds
WebResponse response = request. GetResponse ();
Stream resStream = response. GetResponseStream ();
StreamReader sr = new StreamReader (resStream );
String tempstr = sr. ReadToEnd ();
Regex r1 = new Regex ("<input type = \" hidden \ "name = \" _ EVENTTARGET \ ". */>", RegexOptions. IgnoreCase );
Regex r2 = new Regex ("<input type = \" hidden \ "name = \" _ EVENTARGUMENT \ ". */>", RegexOptions. IgnoreCase );
Regex r3 = new Regex ("<input type = \" hidden \ "name = \" _ VIEWSTATE \ ". */>", RegexOptions. IgnoreCase );
// Filter <form> code
Regex r4 = new Regex ("<form name = \" aspnetForm \ ". * id = \" aspnetForm \ ">", RegexOptions. IgnoreCase );
Regex r5 = new Regex ("</form> ");
Tempstr = r1.Replace (tempstr ,"");
Tempstr = r2.Replace (tempstr ,"");
Tempstr = r3.Replace (tempstr ,"");
Tempstr = r4.Replace (tempstr ,"");
Tempstr = r5.Replace (tempstr ,"");
Return tempstr;
}