【问题标题】:Opening new tab in internet explorer and getting its source code with vb.net在 Internet Explorer 中打开新选项卡并使用 vb.net 获取其源代码
【发布时间】:2013-09-08 16:45:52
【问题描述】:

有没有办法在已经打开的 Internet Explorer 窗口中打开一个新选项卡并获取其源代码?我发现的大部分信息都包括创建一个新的 Internetexplorer 对象。当我打开 Internet Explorer 的新实例以打开网站时,我尝试访问的安全网页不喜欢它。因此,我想在已经打开的 Internet Explorer 窗口上打开一个新选项卡,以避免安全/cookie 问题。我最终试图获取网站的源代码并从中提取超链接。以下是我到目前为止的想法。任何建议将不胜感激。

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    'Standard module code, like: Module1.
    Dim ie As Object, objDoc As Object

    Const strURI As String = "http://www.cnn.com"

    ie = CreateObject("internetexplorer.application")

    ie.Navigate(strURI)

    'Wait for page to load!
    Do
        If ie.ReadyState = 4 Then
            ie.Visible = True
            Exit Do
        Else
            Application.DoEvents()
        End If
    Loop

    objDoc = ie.Document

    Dim strMyPage As String
    strMyPage = objDoc.body.innerHTML

    TextBox1.Text = strMyPage

    objDoc = Nothing
    ie = Nothing
End Sub

【问题讨论】:

    标签: vb.net internet-explorer vba tabs


    【解决方案1】:

    您可以为此使用FiddlerCore

    为了获取打开标签的源代码,你需要使用WM_GETOBJECT来获取现有文档的IHTMLDocument2接口,然后你可以枚举该文档中的锚对象。

    http://support.microsoft.com/kb/249232 显示一般模式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-16
      • 2015-06-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多