Link to home
Start Free TrialLog in
Avatar of skij
skijFlag for Canada

asked on

ASP.NET / C# : Look for phrase using remote web request

Using ASP.NET/C#, how can I test if a remote website contains a specified phrase?  This does NOT work:
  String strResult;
  WebResponse objResponse;
  WebRequest objRequest = HttpWebRequest.Create("http://www.example.com/");
  objResponse = objRequest.GetResponse();
  using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
  {
    strResult = sr.ReadToEnd();
    Print(strResult);
    sr.Close();
  }
  if( strResult contains "illustrative examples") {
    Console.WriteLine("Phrase Found");
  }
  else {
    Console.WriteLine("Phrase Not Found");
  }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial