i have the same problem of this post http://www.daniweb.com/software-development/vbnet/threads/409118/1746088#post1746088


i cant find the elements of this site that i need to my system. this is the only missing part to my system/project

this is the site : someurl.com

this is the portion that i want to grab
[IMG]http://i1059.photobucket.com/albums/t432/doomhades666/sss12.png[/IMG]


Thanks in advanced.

Recommended Answers

If you view the page source you will see that the text you are after isn't even contained in the page. It is an iFrame which calls a php script to handle the actual maths. Not sure how you are going to get around that...

Jump to Post
Public Class Form1
    Private urlMain As String = "http://www.someurl.com/"
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With WebBrowser1
            .ScriptErrorsSuppressed = True
            .Navigate(urlMain & "solver.html")
        End With
    End Sub

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted …
Jump to Post

All 8 Replies

If you view the page source you will see that the text you are after isn't even contained in the page. It is an iFrame which calls a php script to handle the actual maths. Not sure how you are going to get around that...

Public Class Form1
    Private urlMain As String = "http://www.someurl.com/"
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With WebBrowser1
            .ScriptErrorsSuppressed = True
            .Navigate(urlMain & "solver.html")
        End With
    End Sub

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        With WebBrowser1
            txt.Text = .Url.AbsoluteUri
            If .Url.AbsoluteUri = urlMain & "_answer.php" Then '// 1. check if url is the page w/the answer on it.
                .Navigate(urlMain & .Document.GetElementById("centerContentFrame").GetAttribute("src")) '// 2. extract url from iFrame and .Navigate to it.
                '// 3. Thank "hericles" for pointing out the <iframe> and getting you a quicker solution from .Me.
            End If
        End With
    End Sub
End Class

:)

Well, there you go. And I learnt something too. A good day...

Thanks for the reply guys specially to codeorder for the code

But i have a problem now on putting the values from textboxes and the button

this is my code

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        With WebBrowser1
            TextBox4.Text = .Url.AbsoluteUri
            If .Url.AbsoluteUri = urlMain Then
                With .Document
                    .GetElementById("lhs").SetAttribute("value", TextBox1.Text)
                    .GetElementById("rhs").SetAttribute("value", TextBox2.Text)
                    .GetElementById("variable").SetAttribute("value", TextBox3.Text)
                    .GetElementById("Solve it...").InvokeMember("submit")
                End With
            End If
            If .Url.AbsoluteUri = urlMain & "_answer.php" Then '// 1. check if url is the page w/the answer on it.
                .Navigate(urlMain & .Document.GetElementById("centerContentFrame").GetAttribute("src")) '// 2. extract url from iFrame and .Navigate to it.
                '// 3. Thank "hericles" for pointing out the <iframe> and getting you a quicker solution from .Me.
            End If
        End With
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Navigate(urlMain)

this is the image that i want to get the values and put it on my textboxes and button.
[IMG]http://i1059.photobucket.com/albums/t432/doomhades666/ss241.png[/IMG]

Had to modify quite a bit of code for you to post values to those <input/> TextBoxes since no IDs on them, though Nothing major.

Public Class Form1
    Private urlMain As String = "http://www.someurl.com/"

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With WebBrowser1
            .ScriptErrorsSuppressed = True
            .Navigate(urlMain & "solver.html")
        End With
    End Sub

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        With WebBrowser1
            txt.Text = .Url.AbsoluteUri
            Select Case .Url.AbsoluteUri
                Case urlMain & "solver.html"
                    With .Document '// since no IDs on the elements, locate all <input/> TextBoxes and set values as needed.
                        For Each elm As HtmlElement In .GetElementsByTagName("input")
                            With elm
                                If .Name = "lhs" Then .SetAttribute("value", TextBox1.Text)
                                If .Name = "rhs" Then .SetAttribute("value", TextBox2.Text)
                                If .Name = "variable" Then .SetAttribute("value", TextBox3.Text)
                            End With
                        Next
                        .Forms(1).InvokeMember("submit")
                    End With
                Case urlMain & "_answer.php"
                    .Navigate(urlMain & .Document.GetElementById("centerContentFrame").GetAttribute("src")) '// 2. extract url from iFrame and .Navigate to it.
            End Select
        End With
    End Sub
End Class

.btw, I also learned something from this; how to properly make use of the .GetElementsByTagName and I might just use that on my adventure to rob the internet of <input/> TextBoxes.:D

Hope this helps.:)

wow thanks for the quick answer. but how can i add a button on it? because it automatically calculating.

.Remove(.Navigate(urlMain & "solver.html")) from Form1_Load and add it to the top of your hat:D; that is if your hat is a Button, otherwise add it to a Button.:)

thanks man it works. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.