views:

268

answers:

1

I need to check if a webpage exists if it does whether a certain string exists anywhere on the page. Preferably I'd like to do this without a webbrowser control, so that images don't have to be downloaded and it doesn't have to be rendered.

So is there a way to do this?

+1  A: 

First, follow the instructions here (Though, the instructions are in C#, they should easily be converted to VB.)

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

Dim stringFound = result.IndexOf("My search string")
Ryan Hayes