获取特定网站数据到excel单元格

时间:2015-06-27 07:13:26

标签: excel vba excel-vba

我是vba的新手并尝试编写代码以将以下网站中的某些特定数据提取到excel中 http://www.sec.gov/Archives/edgar/data/1646124/000114036115025436/xslFormDX01/primary_doc.xml

例如,我想提取一些具体数据,如公司名称,提供的证券类型,发行和销售金额,回应澄清(如有必要),申请类型,首次销售日期等..从上面的url到不同的excel单元格,但在同一行。

我有以下代码,但我不明白如何将它用于我的目的..

Sub GetData()
    Dim IE As New InternetExplorer

    IE.navigate "kieskeurig.nl/zoeken/index.html?q=4960999543345"
    IE.Visible = False
    Do
        DoEvents
    Loop Until IE.readyState = READYSTATE_COMPLETE

    Dim doc As HTMLDocument
    'variable for document or data which need to be extracted out of webpage
    Set doc = IE.Document

    Dim dd As Variant
    dd = doc.getElementsByClassName("lgn")(0).outerHtml
    'Range("a1").Value = dd
End Sub

1 个答案:

答案 0 :(得分:1)

Sub GetData()

Dim IE As New InternetExplorer
IE.navigate "http://www.sec.gov/Archives/edgar/data/1646124/000114036115025436/xslFormDX01/primary_doc.xml"
IE.Visible = False

Do
    DoEvents
Loop Until IE.readyState = READYSTATE_COMPLETE

Application.Wait (Now() + TimeValue("00:00:016")) 
Dim doc As HTMLDocument 
Set doc = IE.document
Dim dd As Variant
dd = doc.getElementsByClassName("lgn")(0).outerHtml
'Range("a1").Value = dd
MsgBox dd

End Sub