Categories
Articles

How To Check a Web Page For a String Using .NET C# Using HttpWebRequest

using System.Text;
using System.Net;using System.IO;
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(URL);myRequest.Method = "GET";WebResponse myResponse = myRequest.GetResponse();StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8);string result = sr.ReadToEnd();sr.Close();myResponse.Close();

//Now, once you have this, perform the search on result string
int stringFound = result.IndexOf("My search string");