【问题标题】:Extract data from a website using VBA使用 VBA 从网站中提取数据
【发布时间】:2013-06-19 17:39:52
【问题描述】:

我正在尝试从网页http://www.fdci.org/Member.aspx?mid=-1634884325&cat=1 和许多其他类似的网页中提取数据。

我需要将个人资料、姓名、地址、电子邮件、电话、传真等从网页获取到 Excel 工作表的不同列。如果您可以为此共享 VBA 代码,或者任何帮助都将受到欢迎。

PS:我是 VBA 编码的新手。

【问题讨论】:

  • “相似”是什么意思?其他网站的结构是否相同?
  • 同一网站链接上的其他链接!!

标签: html excel vba web


【解决方案1】:

您可以使用MSXML2.XMLHTTP60来获取页面,例如地址。

' Add reference to MS XML, v6.0 and MS HTML Object Library

Public Sub test()

    Dim xmlObject As New MSXML2.XMLHTTP60
    Dim htmlDocumentObject As Object

    With xmlObject
        Call .Open("GET", "http://www.fdci.org/Member.aspx?mid=-1634884325&cat=1", False)
        Call .send

        If (.Status = 200) Then
            Set htmlDocumentObject = New HTMLDocument
            htmlDocumentObject.Open
            htmlDocumentObject.write .responseText
            htmlDocumentObject.Close

            Dim address As String
            address = htmlDocumentObject.getElementById("ctl00_ContentPlaceHolder1_lblAdd1").innerText

            [a1] = address
            ' and so on ...
        End If
    End With
End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-19
    相关资源
    最近更新 更多