InternetExplorer.Application

来源:互联网 发布:淘宝买了电动车后悔了 编辑:程序博客网 时间:2024/04/24 12:57
strIText = GetInnerX("http://www.heise.de","TEXT")
Open "C:/Inner.txt" For Output As #1
Print #1, strIText
Close 1

Function GetInnerX(strURL As String, Optional strWhat As String = "HTML") As String
    Dim IEApp As Object
    Dim IEDoc As Object
    GetInnerX = ""
    Set IEApp = CreateObject("InternetExplorer.Application")
    If Not IEApp Is Nothing Then
        IEApp.Visible = False
        IEApp.Navigate strURL
        Do: Loop Until IEApp.Busy = False
        Do: Loop Until IEApp.Busy = False
        Set IEDoc = IEApp.Document
        Select Case UCase(strWhat)
            Case "HTML"
                GetInnerX = IEDoc.Body.InnerHTML
            Case Else
                GetInnerX = IEDoc.Body.InnerText
        End Select
        IEApp.Quit
        Set IEDoc = Nothing
        Set IEApp = Nothing
    Else
        MsgBox "InternetExplorer nicht installiert?", vbInformation
    End If
End Function