我正在尝试在VB.NET中创建一个应用程序,它将登录到一个特定的网站,到目前为止这是有效的,但我想知道有一种方式,在你登录后,在新的形式类似的功能在Internet Explorer中到达页面。到目前为止我的代码是:
Dim ie As Object
ie = CreateObject("internetexplorer.application")
ie.Navigate("http://forums.macrumors.com/")
ie.Visible = True
While Not ie.ReadyState = WebBrowserReadyState.Complete
Application.DoEvents()
End While
If ie.Document IsNot Nothing Then
ie.Document.All("vb_login_username").SetAttribute("value", "user-name-here")
ie.Document.All("vb_login_password").SetAttribute("value", "Password-here")
ie.Document.getElementsByTagName("input").item(20).Click()
End If
这段代码让我登录但是一旦我到达下一页,我想执行类似的任务,有什么提示吗?
答案 0 :(得分:0)
如果您计划对此逻辑进行硬编码,则需要导航DOM
并在登录后找到您所指的特定输入框的element id
。
例如
WebBrowser1.Document.Forms[0].All["textField"].SetAttribute("value", "hello world");
WebBrowser1.Document.GetElementById("btn_login").Focus();
WebBrowser1.Document.GetElementById("btn_login").InvokeMember("submit")