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 th开发者_StackOverflow中文版is 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?
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")
精彩评论