Results 1 to 11 of 11

Thread: getting text from html/php page

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2009
    Posts
    29

    getting text from html/php page

    hello people

    tell me how can i get text from a html page and set a conditional statement with it


    thanks

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: getting text from html/php page

    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:
    1. For Each ele In ie.document.getelementsbytagname("a")
    2.     If ele.innertext = "Do you want to upload several files? Please click here" Then ele.Click
    3. Next
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2009
    Posts
    29

    Re: getting text from html/php page

    thanks 4 replying
    im using webbrowser control

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: getting text from html/php page

    there are many ways to work with webpages, depends on the site and what you want to do
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jul 2009
    Posts
    29

    Re: getting text from html/php page

    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

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jul 2009
    Posts
    29

    Re: getting text from html/php page

    cant any1 help me :S

  7. #7
    Member RaZeR's Avatar
    Join Date
    Jan 2009
    Location
    Russia, Moscow
    Posts
    38

    Lightbulb Re: getting text from html/php page

    Quote Originally Posted by asad1912 View Post
    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:
    Code:
    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
    Of course, Google doesn't contain word "LOL", so function in this case will return False

    I hope this will help you
    Last edited by RaZeR; Jul 26th, 2009 at 09:52 AM.
    VB 6, VB.NET, C#, Java, JavaME, C/C++ and Assembler Programmer


    If my post was helpful, rate me

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jul 2009
    Posts
    29

    Re: getting text from html/php page

    can you please give me a little detail on how to deploy this code??

  9. #9
    Member RaZeR's Avatar
    Join Date
    Jan 2009
    Location
    Russia, Moscow
    Posts
    38

    Re: getting text from html/php page

    Quote Originally Posted by asad1912 View Post
    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():
    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
    I can give you a sample project, if you need it
    VB 6, VB.NET, C#, Java, JavaME, C/C++ and Assembler Programmer


    If my post was helpful, rate me

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jul 2009
    Posts
    29

    Re: getting text from html/php page

    that will be gr8...
    a sample project would be amazing

  11. #11
    Member RaZeR's Avatar
    Join Date
    Jan 2009
    Location
    Russia, Moscow
    Posts
    38

    Arrow Re: getting text from html/php page

    Quote Originally Posted by asad1912 View Post
    that will be gr8...
    a sample project would be amazing
    Ok, i attached a sample
    Attached Files Attached Files
    VB 6, VB.NET, C#, Java, JavaME, C/C++ and Assembler Programmer


    If my post was helpful, rate me

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width