Webkit Autologin not working using Document.GetElementsByTagName("input")
I really need to 开发者_如何学编程get this autologin script working with Webkit 0.5 in Visual Basic:
It is intended to run on https://www.ea.com/profile/login
Somehow it doesn't seem to work as I cannot
Dim ElementListe As HtmlElementCollection
Therefore the following is impossible:
For Each Element As HtmlElement In ElementListe
Current Code (not mine):
Private Sub Load()
AlleFelderAusgefüllt = False
Try
BattlelogBrowser.Navigate("https://www.ea.com/profile/login")
Catch ex As Exception
Beep()
End Try
Do While BattlelogBrowser.IsBusy = True
Application.DoEvents()
Loop
Dim ElementListe
ElementListe = WebkitBrowser1.Document.GetElementsByTagName("input")
For Each Element In ElementListe
Select Case Element.GetAttribute("name")
Case "email"
Element.SetAttribute("Value", TextBox1.Text)
Case "password"
Element.SetAttribute("Value", TextBox2.Text)
End Select
Next
For Each Element In ElementListe
If Element.GetAttribute("value").Equals("Login") Then
Element.InvokeMember("click")
End If
Next
End If
End Sub
Any solutions? It worked quite similar with the usual Webbrowser, hence I hoped one of you might be able to edit the code or even create a new one!
Regards, RiX
Use Fiddler or Wireshark to compare what goes over the wire when it works and when it doesn't work... once you know the differences you can change your accordingly...
This way you could be able to achieve what you want without the browser control by using HttpWebRequest
...
Dim doc As WebKit.DOM.Document = WKB.Document
Dim inputs As WebKit.DOM.NodeList = doc.GetElementsByTagName("input")
Dim inputElement As WebKit.DOM.Element
For Each item As WebKit.DOM.Element In inputs
inputElement = DirectCast(item, WebKit.DOM.Element)
Select Case inputElement.GetAttribute("name")
Case "username"
inputElement.SetAttribute("Value", txtAccount.Text)
Case "password"
inputElement.SetAttribute("Value", txtPassword.Text)
End Select
Next
You can submit form by:
For Each item In inputs
inputElement = DirectCast(item, WebKit.DOM.Element)
If inputElement.GetAttribute("value").Equals("Login") Then
WKB.StringByEvaluatingJavaScriptFromString("document.getElementById('smlogin').click()")
End If
Next
精彩评论