Frage

So I'm trying to get the mid-day and evening data off of www.flalottery.com/play4.do. I popped open VB.NET, popped in an Awesomium WebControl 1.7.2 (Latest version), and a label into the form, and this code:

Private Sub Awesomium_Windows_Forms_WebControl_DocumentReady(sender As Object, e As Awesomium.Core.UrlEventArgs) Handles WebControl1.DocumentReady
    Label1.Text = WebControl1.ExecuteJavascriptWithResult("document.getElementsByClassName('gameContent')[0].getElementsByClassName('balls')")
End Sub

But it's showing as undefined. Help? I'm probably missing something super simple. I put a button in to try it after, and I get:

[object] 

And in Chrome I get:

[<span class=​"balls" title=​"4">​4​</span>​, <span class=​"balls" title=​"1">​1​</span>​, <span     class=​"balls" title=​"5">​5​</span>​, <span class=​"balls" title=​"6">​6​</span>​, <span class=​    "balls" title=​"6">​6​</span>​, <span class=​"balls" title=​"5">​5​</span>​, <span class=​"balls"     title=​"5">​5​</span>​, <span class=​"balls" title=​"4">​4​</span>​] 

and that's what I need.

War es hilfreich?

Lösung

I'm pn a restricted network at the moment so I cant look at the page source, but my guess is that this is your problem:

getElementsByClassName('balls')

You need to specify which attribute of which element you want, you're returning an array of html elements there and trying to put them somewhere that requires a text object. Could you not use getElementById() ?

If not,

document.getElementsByClassName('gameContent')[0].getElementsByClassName('balls')[0].getAttribute('textContent')

My knowledge of JS is limited, but I imagine this should work.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top