Other Software > Developer's Corner
[Help] - Check if a webpage contains some text then do something (C#)
KynloStephen66515:
I was already using a webBrowser control and was looking into using the HTML Agility Pack I got off NuGet to do this, but it is seeming like a pain in the ass...Also..I suck BADLY with Regex lol
-Stephen66515 (September 07, 2014, 03:39 PM)
--- End quote ---
You need to decide on which control you will use. I'll use the stock control here.
--- Code: C# ---private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (webBrowser1.DocumentText.Contains("No Messages Found")) { this.Text = "No Messsaged Found found"; } }
That is all you need.
-Renegade (September 08, 2014, 12:52 AM)
--- End quote ---
I couldn't actually get that to even DO anything lol (Although, it does compile...so might be something I did(n't) do.)
hamradio:
One way to not even use the web browser control should be as simple as this...
--- Code: C# ---WebClient myWebClient = new WebClient();string siteSource = myWebClient.DownloadString("PLEASECHANGETOYOURURL"); if (siteSource.Contains("YOURTEXT")){// Your string found code here.}else{// Your string not found code here.}
For more info: (Note: I'm not affiliated with Dot Net Perls in any size, shape, and/or form.)
http://www.dotnetperls.com/webclient
Renegade:
Here's the project:
WebCheckStephen.zip (30.35 kB - downloaded 539 times.)
You can run the debug or compile it yourself. It's done in VS2010.
The WebClient method is actually better, but the way I have that there is a bit more visual with a control, etc. Also, you can actually surf with it.
Navigation
[0] Message Index
[*] Previous page
Go to full version