The attached project is a testbed I'm using for a project where I want to extract some values from a website. I have a fully working version in Visual Basic 2010 and a working testbed in B4A, but I just can't get the extraction working in B4J.
The code:
returns:
[objectHTMLSpanElement]
sun.org.mozilla.javascript.internal.NativeJavaObject@3346e3
sun.org.mozilla.javascript.internal.NativeJavaObject@1ef1245
I saw in another thread that the return of something like sun.org.mozilla.javascript.internal.NativeJavaObject@3346e3 was due to the page not being fully rendered, but this shouldn't be the problem given it's included in a PageFinished sub.
The code which works in B4A is:
Any assistance appreciated.
The code:
B4X:
js.evalString("var x = doc.getElementById('aj_1_score');")
js.evalString("var y = x.innerHTML;")
js.evalString("var t = doc.title;")
Msg.Show(js.engineGet("x"),"engineget_x")
Msg.Show(js.engineGet("y"),"engineget_y")
navBar.Text = js.engineGet("y")
Msg.Show(js.engineGet("t"),"engineget_t")
returns:
[objectHTMLSpanElement]
sun.org.mozilla.javascript.internal.NativeJavaObject@3346e3
sun.org.mozilla.javascript.internal.NativeJavaObject@1ef1245
I saw in another thread that the return of something like sun.org.mozilla.javascript.internal.NativeJavaObject@3346e3 was due to the page not being fully rendered, but this shouldn't be the problem given it's included in a PageFinished sub.
The code which works in B4A is:
B4X:
Sub WebView1_PageFinished (Url As String)
' Now that the web page has loaded we can get the data we want
' see the documentation http://www.b4x.com/forum/additional-libraries-classes-official-updates/12453-webviewextras.html#post70053 for details of the second parameter callUIThread
Dim Javascript As String
For count = 1 To 2
TeamScore = "aj_"&count&"_score"
Javascript="B4A.CallSub('ProcessHTML', true, document.getElementById('"&TeamScore&"').innerHTML, '"&TeamScore&"')"
'Log("PageFinished: "&Javascript)
WebViewExtras1.executeJavascript(WebView1, Javascript)
Next
End Sub
Sub ProcessHTML(Html As String, Team As String)
' This is the Sub that processes the extracted data
'Log(Team & " = " & Html)
Msgbox(Html,Team)
End Sub
Any assistance appreciated.