hello people
tell me how can i get text from a html page and set a conditional statement with it
thanks
Printable View
hello people
tell me how can i get text from a html page and set a conditional statement with it
thanks
you do not give much idea of what you want to do or how you want to do it
if using a webbrowser control or automation of internet explorer
vb Code:
For Each ele In ie.document.getelementsbytagname("a") If ele.innertext = "Do you want to upload several files? Please click here" Then ele.Click Next
thanks 4 replying
im using webbrowser control ;)
there are many ways to work with webpages, depends on the site and what you want to do
its a php webpage
i wanna make a condition
that if the webpage contains the specified text then giv a msgbox saying yes
if it doesnt then say no
cant any1 help me :S
Add a a reference to "Microsoft Internet Transfer Control", then place Inet control to the form and add this function:
Code:Private Function ConditionString(URL As String, Condition As String) As Boolean
Dim tmpStr As String
Dim tmpMass() As String
tmpStr = Inet1.OpenURL(URL)
tmpMass = Split(tmpStr, Condition)
If UBound(tmpMass) <> 0 Then
ConditionString = True
Else
ConditionString = False
End If
End Function
Function returns boolean (True or False). Use it like this:
Of course, Google doesn't contain word "LOL", so function in this case will return False :DCode:Dim tmp As Boolean
tmp = ConditionString("www.google.com", "LOL")
If tmp = True Then
MsgBox "Webpage contains this text!"
Else
MsgBox "Webpage doesn't contain this text!"
End If
I hope this will help you ;)
can you please give me a little detail on how to deploy this code??
Ok. For example, on form you have a WebBrowser named WebBrowser1, a textbox for URL named txtAdress and a button named cmdCheckWord. Put my function in the code and put this code into cmdCheckWord_Click():
I can give you a sample project, if you need it :)Code:Dim WordToCheck as string
WordToCheck = InputBox "Enter a word to compare: "
If ConditionString(txtAdress, WordToCheck = True Then
MsgBox "Webpage contains this text!"
Else
MsgBox "Webpage doesn't contain this text!"
End if
that will be gr8...
a sample project would be amazing ;)