Scrape li tags tat shares the same class name

RKROX907

New Member
Joined
Mar 27, 2017
Messages
17
Hi Everyone. i am trying to scrape li tags that shares the same class name
the HTML cods looks like this:

HTML:
<ul class="top-section-list" data-selenium="highlightList">    
                <li class="top-section-list-item">sample text# 1</li>           
                <li class="top-section-list-item">sample text# 2</li>            
                <li class="top-section-list-item">sample text# 3</li>           
                <li class="top-section-list-item">sample text# 4</li>            
                <li class="top-section-list-item">sample text# 5</li>     
        </ul>

my current code

Code:
Sub GetData()
 
    Dim objIE As InternetExplorer
    Dim itemEle As Object
    Dim data As String
    Dim y As Integer
 
    Set objIE = New InternetExplorer
    objIE.Visible = True
 
    objIE.navigate "someWebsite"
    Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
 
    y = 1
 
    For Each itemEle In objIE.document.getElementsByClassName("top-section-list")
    data = itemEle.getElementsByTagName("li")(0).innerText
        y = y + 1
    Next
    data = Range("A1").Value
End Sub

only writes to cells A1: "sample text# 1"
how can i have all the tags to be written to cell A1?
desired result would be cell A1:
sample text# 1
sample text# 2
sample text# 3
sample text# 4
sample text# 5

Any help will be great
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,215,743
Messages
6,126,609
Members
449,321
Latest member
syzer

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top