抓SVG HTML

时间:2016-06-18 09:50:08

标签: html vba svg scrape

我想知道是否有人能告诉我这是否可能,因为我已经碰到了一堵砖墙。不寻找有人为我做这件事,只要在正确的方向上轻推就会很棒。

我正在使用VBA抓取link

更具体地说,我正试图刮掉SVG元素的圆形标记坐标。我能够深入到div类sqw_icons没问题。

我可以返回SVG的属性,例如高度和宽度。但我似乎无法找到一种方法来获取其下的g类元素。

我的印象是它可能因为它们是HTML集合。

任何想法都会非常有用。

以下是代码:

Sub ImportSqw()

    Dim ie As InternetExplorer
    Dim html As HTMLDocument

    Set ie = New InternetExplorer
    ie.Visible = False
    ie.Navigate "http://epl.squawka.com/english-barclays-premier-league/17-05-2016/man-utd-vs-b-mouth/matches"

    Do While ie.readyState <> READYSTATE_COMPLETE
        DoEvents
    Loop

    Set html = ie.Document
    Set ie = Nothing
    Application.StatusBar = ""
    Cells.Clear

    Dim levelOne As IHTMLElement
    Dim levelTwo As IHTMLElementCollection
    Dim levelThree As IHTMLElement
    Dim levelFour As IHTMLElementCollection
    Dim levelFive As IHTMLElement
    Dim levelSix As IHTMLElementCollection

    Set levelOne = html.getElementById("mc-pitch-view")
    Set levelTwo = levelOne.Children

    For Each levelThree In levelTwo
        If levelThree.className = "sqw_pitch_container" Then
            Set levelFour = levelThree.Children
        End If
    Next

    For Each levelFive In levelFour
        If levelFive.className = "sqw_icons" Then
            Set levelSix = levelFive.Children
        End If
    Next

    Set html = Nothing

End Sub

levelSix中的项目没有子项属性。

0 个答案:

没有答案