Hello. I was wondering how to find a string in a webpage.
say i opened a website and i want to check if it contains a string e.g. "glasgow rangers" and if it contained that then my computer will beep.
Printable View
Hello. I was wondering how to find a string in a webpage.
say i opened a website and i want to check if it contains a string e.g. "glasgow rangers" and if it contained that then my computer will beep.
Put a webbrowser control on your page.
YOu can navigate to the desired page by calling the Navigate method:
vb Code:
WebBrowser1.Navigate "http://www.mywebsite.com"
You can get the InnerText and see if it contains what you want:
vb Code:
Dim PageText As String Dim SearchText as String SearchText = "glasgow rangers" PageText = WebBrowser1.Document.Body.InnerText If InStr(PageString, SearchText) > 0 Then Msgbox "Found" Else MsgBox "Not Found" End If
NB: None of the above code is tested. I just typed it here, so it might have spelling mistakes too. The sole intention was to make you understand how to go about it. Please let me know if something doesn't work.