我与 GeckoFX 合作了一段时间。但是现在我在获取通过单击具有 target="_blank" 属性的链接打开的站点的 HTML 时遇到了问题。
PromptFactory.PromptServiceCreator = Function() New MyPromptService()
Xpcom.ProfileDirectory = "C:\gecko-cache"
Xpcom.Initialize("Firefox")
Dim form3 As New Form
Browser = New GeckoWebBrowser()
Browser.Visible = True
form3.Controls.Add(Browser)
Browser.navigate("http://www.asd.com")
browser_wait_javascript(5)
Browser.Document.GetElementsByTagName("a").(0).Click()
browser_wait_javascript(5)
现在浏览器在新窗口中打开此链接的内容。如何获取 HTML 代码,点击新窗口中的链接?我喜欢这样的东西:
dim new_browser_window = get_window(last_opened_window)
dim html = new_browser_window.document.getelementsbytagname("body").(0).outerHTML
实现这一目标的最佳方法是什么?
非常感谢
Public Sub browser_wait_javascript(ByVal maxTimeout As Integer)
Dim maxTimeouttime As DateTime = DateTime.Now.AddSeconds(maxTimeout)
While DateTime.Now < maxTimeouttime
System.Threading.Thread.Sleep(0)
System.Windows.Forms.Application.DoEvents()
System.Threading.Thread.Sleep(100)
End While
While Browser.IsBusy()
System.Threading.Thread.Sleep(0)
System.Windows.Forms.Application.DoEvents()
System.Threading.Thread.Sleep(100)
End While
End Sub