使用VBA从网站提取数据 [英] Extract data from a website using VBA

查看:175
本文介绍了使用VBA从网站提取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to extract the data from the webpage http://www.fdci.org/Member.aspx?mid=-1634884325&cat=1 and many others similar to this.

我需要得到个人资料,姓名,地址,电子邮件,电话,传真等从网页到Excel表格的不同列。如果您可以共享VBA代码或者任何帮助,将是非常好的。

I need to get the Profile, Name, Address, Email, phone,fax, etc. from the webpage to different columns of an excel sheet. Would be great if you can share the VBA code for this or any help would be welcome.

PS:我是VBA编码的新手。

PS: I am new to VBA Coding.

推荐答案

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

You can use MSXML2.XMLHTTP60 to get page, example for address.

' 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

这篇关于使用VBA从网站提取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆