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...
hericles
Practically a Posting Shark
823 posts since Nov 2007
Reputation Points: 136
Solved Threads: 167
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
:)
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
Well, there you go. And I learnt something too. A good day...
hericles
Practically a Posting Shark
823 posts since Nov 2007
Reputation Points: 136
Solved Threads: 167
Had to modify quite a bit of code for you to post values to those 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 TextBoxes.:D
Hope this helps.:)
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
.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.:)
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384