来自相同类名VBA的多个元素

时间:2015-03-18 06:38:56

标签: excel-vba vba excel

我想将所有价格数据从网站中拉出来这个给定的代码仅适用于第一个价格。

如何获取所有其他价格表才能擅长?

Sub PriceGetting()  
    Dim IE As New InternetExplorer 
    Dim Element As IHTMLElement  
    Dim i As Integer    

    IE.navigate "http://www.junglee.com/dp/B00QG8BS6U"   
    IE.Visible = True   

    Do    
        DoEvents  
    Loop Until IE.readyState = READYSTATE_COMPLETE    

    Dim doc As HTMLDocument     
    Set doc = IE.document    

    Dim dd As Variant    

    dd = doc.getElementsByClassName("whole-price")(0).innerText    

    i = 1   
    Do While i < 20    
        dd = doc.getElementsByClassName("whole-price")(0).innerText  
        Range("A" & i + 1) = dd    
        i = i + 1    
    Loop    
End Sub

0 个答案:

没有答案