用于从下拉列表中选择符号的vba代码

时间:2017-01-19 10:11:25

标签: html vba excel-vba web-scraping excel


我是新来的,需要为我的模块提供一些建议。我创建了一个简单的模块来废弃数据。
特定值嵌套在以下元素中:

<button class="dropdown-toggle control-button review-control-button" data-toggle="dropdown">
    <i class="icon-star-empty icon-large"></i>
    <span data-bind="text: rating() === 'all' ? 'All Ratings' : rating() + ' Star'">All Ratings</span>
    <span class="caret"></span>
</button>
<div class="arrow">
    ::before
</div>
<ul class="dropdown-menu" style="min-width: 0px;">
    <li>
        <a class="selected-filter-option" href="#" data-bind="css: { 'selected-filter-option': rating() === 'all' }, click: function() { rating('all') }, sense: ['App Intel - Review History - Ratings Filter Change', { 'Filter Selected': 'All Ratings' }]">All Ratings</a>
    </li>
    <li>
        <a href="#" data-bind="css: { 'selected-filter-option': rating() === 5 }, click: function() { rating(5) }, sense: ['App Intel - Review History - Ratings Filter Change', { 'Filter Selected': '5 Stars' }]">
            5 Star
            <span class="review-star-symbol">★★★★★</span>
        </a>
    </li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
</ul>

我只需要点击代码点击5星★★★★★的评论
这是我的模块:

Sub TestApp()

Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
    .Visible = True
    .navigate "https://sensortower.com/android/id/miniclip-com/app/8-ball-pool/com.miniclip.eightballpool/#review-history?reviews"
    Do Until Not IE.Busy And IE.readyState = 4
        DoEvents
    Loop
End With

IE.document.getElementsByClassName("dropdown-toggle control-button review-control-button")(0).Click
    Application.Wait (Now + TimeValue("00:00:2"))

Dim starsym
For Each starsym In IE.document.getElementsByClassName("dropdown-menu")(0).getElementsByTagName("a")(1) 
    If starsym.innerText = "5 Star" Then
    starsym.Click
    End If
    Next starsym

End Sub

图片下拉列表如下所示: dropdown list

我没有做什么让代码做它应该做的事情?

0 个答案:

没有答案