Hi - I want to scrap product title, price, seller and image url from an eCommerce website. The results need to be copied to active sheet in column A-D. I am using the following code originally developed for Amazon. Any help to update it to get the desired result?
Website: https://www.daraz.lk/catalog/?from=input&q=sarees&ppath=31186:3287
HTML of product title: <a age="0" href="//www.daraz.lk/products/ladies-office-and-saree-wear-brown-i102604104-s1009196133.html?spm=a2a0e.searchlist.list.2.6bd4c8e94qkafn&search=1" title="Ladies Office And Saree Wear - Brown" data-spm-anchor-id="a2a0e.searchlist.list.2">Ladies Office And Saree Wear - Brown</a>
I need help to update the following code lines:
Set titles =.querySelectorAll(".c3gUW0,.c13VH6")
Set prices =.querySelectorAll(".------------")&
results(r +1,1)= titles.Item(r).innerText
I have included the image how the result will look like. Thanks
[/CODE]
PublicSub Amazon_Pro()
'VBE>Tools>References> Microsoft HTML Object Library
Dim html As MSHTML.HTMLDocument
Set html =New MSHTML.HTMLDocument
With CreateObject("MSXML2.XMLHTTP")
' change the url for the page of amazon from where to copy data
.Open "GET","https://www.daraz.lk/catalog/?from=input&q=sarees&ppath=31186:3287",False
.setRequestHeader "User-Agent","Mozilla/5.0"
.send
html.body.innerHTML =.responseText
EndWith
' 1. declare additional headers as variable
Dim headers(), titles AsObject, prices AsObject, original_prices AsObject
Dim seller AsObject
headers = Array("Title","Price")
With html
Set titles =.querySelectorAll(".c3gUW0,.c13VH6")
Set prices =.querySelectorAll(".------------")
EndWith
Dim results(), r AsLong, priceInfo AsString
ReDim results(1To titles.Length,1To UBound(headers)+1)
For r =0To titles.Length -1
results(r +1,1)= titles.Item(r).innerText
Next
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sheet1")
With ws
.Cells(1,1).Resize(1, UBound(headers)+1)= headers
.Cells(2,1).Resize(UBound(results,1), UBound(results,2))= results
EndWith
Endsub