Extract Image URL(s) from eBay.co.uk Listings

razzandy

Active Member
Joined
Jun 26, 2002
Messages
400
Office Version
  1. 2007
Platform
  1. Windows
Hi Guys, its been a while!

I have a list of eBay item numbers, lets say in Column A and I want to read down the list of item numbers and extract the Image URL(s) into Column B Separated by a Comma. The image URL are like this: https://i.ebayimg.com/images/g/-DcAAOSwzrxUwnIS/s-l500.jpg and they all start with https://i.ebayimg.com/images/g/ and end with s-l500.jpg but some listing may have 1 photo and other may have 10 photos. I have inspected the HMTL and found they appear like this: <div class="ux-image-carousel-item active image" data-idx="0"> with each extra image the: data-idx="0" increases by 1.

Thanks in advance (y)
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
To do the job you need the "Selenium environment" that should be installed on your computer.
If you are interested, you'll find the instruction on how installing it in this message: extract data from web to inside sheet without open website &refersh

After the installation you should be able to open Ebay using Chrome, access the elements and scrape some information via macro.
For example, using this macro:
Code:
Sub EbaySel()
Dim WPage As Object
Dim PColl As Object, PPUrl As String
Dim I As Long, J As Long
'
Set WPage = CreateObject("Selenium.WebDriver")
WPage.Start "chrome"
For I = 2 To Cells(Rows.Count, "A").End(xlUp).Row
    WPage.Get Cells(I, 1)
    WPage.Wait 500
    Set PColl = WPage.FindElementsByClass("ux-image-carousel-item")
    For J = 1 To PColl.Count
        PPUrl = PColl(J).FindElementByTag("img").Attribute("src")
        If Len(PPUrl) < 5 Then PPUrl = PColl(J).FindElementByTag("img").Attribute("data-src")
        Debug.Print J, PPUrl
        Cells(I, 2 + J).Clear
        Cells(I, 2 + J).Value = PPUrl
        ActiveSheet.Hyperlinks.Add anchor:=Cells(I, 2 + J), Address:=PPUrl
        DoEvents
    Next J
Next I
Set WPage = Nothing
MsgBox ("Completed")
End Sub
Copy the code into a standard module of your vba project. Then you need to create a list of items to be searched in column A, then run Sub EbaySel.
It will open Chrome, navigate to each of the urls, copy on column C and subsequents the picture url and set a hyperlink to the url

As shown in the attached picture
 

Attachments

  • EBAY-Pics_Immagine 2022-10-11 191019.jpg
    EBAY-Pics_Immagine 2022-10-11 191019.jpg
    74.2 KB · Views: 26
Upvote 0
To do the job you need the "Selenium environment" that should be installed on your computer.
If you are interested, you'll find the instruction on how installing it in this message: extract data from web to inside sheet without open website &refersh

After the installation you should be able to open Ebay using Chrome, access the elements and scrape some information via macro.
For example, using this macro:
Code:
Sub EbaySel()
Dim WPage As Object
Dim PColl As Object, PPUrl As String
Dim I As Long, J As Long
'
Set WPage = CreateObject("Selenium.WebDriver")
WPage.Start "chrome"
For I = 2 To Cells(Rows.Count, "A").End(xlUp).Row
    WPage.Get Cells(I, 1)
    WPage.Wait 500
    Set PColl = WPage.FindElementsByClass("ux-image-carousel-item")
    For J = 1 To PColl.Count
        PPUrl = PColl(J).FindElementByTag("img").Attribute("src")
        If Len(PPUrl) < 5 Then PPUrl = PColl(J).FindElementByTag("img").Attribute("data-src")
        Debug.Print J, PPUrl
        Cells(I, 2 + J).Clear
        Cells(I, 2 + J).Value = PPUrl
        ActiveSheet.Hyperlinks.Add anchor:=Cells(I, 2 + J), Address:=PPUrl
        DoEvents
    Next J
Next I
Set WPage = Nothing
MsgBox ("Completed")
End Sub
Copy the code into a standard module of your vba project. Then you need to create a list of items to be searched in column A, then run Sub EbaySel.
It will open Chrome, navigate to each of the urls, copy on column C and subsequents the picture url and set a hyperlink to the url

As shown in the attached picture
Thank you very much, I will try this out tomorrow. I didn't know about Selenium! I wondered what could be used instead of the outdated ie.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,217
Members
452,619
Latest member
Shiv1198

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