好的,所以这个网站http://dogwars.com/app/
我正在制作一个应用程序,您可以在其中登录和东西。
但是网站上的登录按钮:
<div style="margin-left: 77px; margin-top: 20px; height: 40px;">
<a href="#" onclick="document.getElementById('loginForm').submit();" class="button"><span>Login</span></a>
</div>
对于我在 VB.net 上的自动提交按钮,我使用这个:
If curElement.GetAttribute("onclick").Equals("document.getElementById('loginForm').submit();") Then
curElement.InvokeMember("click")
End If
但它不会自动登录,我很困惑为什么它不会..?
有人可以帮我吗?这是我的完整代码:
Public Class Form1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
WebBrowser1.Navigate("http://dogwars.com/app/")
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each curElement As HtmlElement In theElementCollection
Dim controlName As String = curElement.GetAttribute("name").ToString
If controlName = "email" Then
curElement.SetAttribute("Value", TextBox1.Text)
ElseIf controlName = "password" Then
curElement.SetAttribute("Value", TextBox2.Text)
End If
Next
theElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each curElement As HtmlElement In theElementCollection
If curElement.GetAttribute("onclick").Equals("document.getElementById('loginForm').submit();") Then
curElement.InvokeMember("click")
End If
Next
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class