get data with product variations using vba

amo

Board Regular
Joined
Apr 14, 2020
Messages
141
Office Version
  1. 2010
Platform
  1. Windows
In one product, there are several choices of product variations such as color and size

this is the site https://shopee.co.id/sepatu-gunung-...utdoor-touring-beckham-i.234869233.4319432435

can someone help improve my code

I want to get data :
price variations
stock variations
size and color variations

VBA Code:
Sub trial()

    Dim Ie As InternetExplorer
    Dim html As HTMLDocument
    Dim URLNAME As String
    Dim sht As Worksheet
    Dim stock As String
    Dim tag As Object
    Dim price  As String
    
    Dim EndRow As Long, i As Long   'ADDED
 
    Set sht = ActiveSheet
    EndRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row
    
    
    
    For i = 3 To EndRow
        URLNAME = Cells(i, 1).Value
        On Error Resume Next
        Set Ie = New InternetExplorer
        Ie.Visible = true  'to allow you to see what is going on
        'Application.Wait (Now + TimeValue("00:00:05"))
        Ie.navigate URLNAME
        On Error Resume Next
        Do
            DoEvents
            Application.Wait (Now + TimeValue("00:00:05"))    
        Loop Until Ie.readyState = READYSTATE_COMPLETE
        Set html = Ie.document

        On Error Resume Next
    
    price = html.getElementsByClassName("AJyN7v")(0).innerText
    For Each tag In html.getElementsByClassName("flex items-center _2_ItKR")
        stock = tag.getElementsByTagName("Div")(1).innerText
    Next
    
   
    
        Sheet3.Cells(i, 4) = price
        Sheet3.Cells(i, 5) = stock

        
        Ie.Quit
        Set Ie = Nothing
        Application.StatusBar = ""
        On Error GoTo 0

    Next i
End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,215,729
Messages
6,126,525
Members
449,316
Latest member
sravya

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