Scraper url Image

amo

Board Regular
Joined
Apr 14, 2020
Messages
141
Office Version
  1. 2010
Platform
  1. Windows
Hello friends

I have a code to retrieve data on the web, but a problem arises. Can only take 1 url image only

my target:

1. Scrape all url images <product images> that are on the web and put in the worksheet


can anyone help me

this is my code

VBA Code:
Sub scraper_Lazada()

Dim ie As InternetExplorer
    Dim html As HTMLDocument
    Dim URLNAME As String
    Dim LastRow As Long
    Dim judul As String
    Dim price  As String
    Dim deskripsi As String
    Dim highlits As String
    Dim kategori As String
    Dim gbr1 As String
    Dim merk As String
    Dim ElementCol As Object, Link As Object
    Dim ecol As Long

    
    
    Dim Baris_akhir As Long, i As Long

Application.ScreenUpdating = False

Set sht = ThisWorkbook
Baris_akhir = sht.Worksheets("Scraper").Range("A" & Rows.Count).End(xlUp).Row


For i = 2 To Baris_akhir
        URLNAME = Cells(i, 1).Value
     
        Set ie = New InternetExplorer
        ie.Visible = True
        Application.Wait (Now + TimeValue("00:00:05"))
        ie.navigate URLNAME
        Do While ie.readyState <> READYSTATE_COMPLETE
Loop
       

'unable to verify these lines
        On Error Resume Next
        judul = html.getElementsByClassName("pdp-mod-product-badge-title")(o).innerText
        price = html.getElementsByClassName(" pdp-price pdp-price_type_normal pdp-price_color_orange pdp-price_size_xl")(o).innerText
        ganti = Replace(Replace(Replace(price, "Rp", ""), ".", ""), ",-", "")
        deskripsi = html.getElementsByClassName("html-content detail-content")(o).innerText
        highlits = html.getElementsByClassName("html-content pdp-product-highlights")(o).innerText
        merk = html.getElementsByClassName("pdp-link pdp-link_size_s pdp-link_theme_blue pdp-product-brand__brand-link")(o).innerText
        kategori1 = html.getElementsByClassName("breadcrumb_list breadcrumb_custom_cls")(o).innerText
        gbr1 = html.getElementsByClassName("pdp-mod-common-image gallery-preview-panel__image")(0).getAttribute("src")
        ganti1 = Application.WorksheetFunction.Substitute(gbr1, "//id-test-11.slatic.net", "https://id-test-11.slatic.net")
       
        kategori1 = html.getElementsByClassName("breadcrumb_list breadcrumb_custom_cls")(o).innerText
        Worksheets("Scraper").Cells(i, 2) = judul
        Worksheets("Scraper").Cells(i, 3) = ganti
        Worksheets("Sheet1").Cells(i, 1) = deskripsi
        Worksheets("Sheet1").Cells(i, 2) = highlits
        'Worksheets("Scraper").Cells(i, 8) = ganti1
        Worksheets("Sheet1").Cells(i, 3) = kategori1
        Worksheets("Scraper").Cells(i, 6) = merk
        ie.Quit
        Set ie = Nothing
        Application.StatusBar = ""
        On Error GoTo 0

    Next i
    
End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
example :


 
Upvote 0

Forum statistics

Threads
1,214,402
Messages
6,119,304
Members
448,886
Latest member
GBCTeacher

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