Multiple Web Page Scrape!

gswizzle

New Member
Joined
Jun 11, 2015
Messages
9
Hi! I want to grab all the search results from this page: Motorcycles | eBay I have a macro that grabs the first 200, how can I change it to grab all of them instead? Thanks!
Code:
Sub ListURLs()

    Dim Anchors As Object
    Dim HTMLdoc As Object
    Dim Rng As Range
    Dim row As Long
    Dim URL As Variant
    Dim Wks As Worksheet
    
        URL = "http://www.ebay.com/sch/Motorcycles-/6024/i.html?_nkw=&_dcat=6024&rt=nc"
        
        Set Wks = Worksheets("Sheet1")
        Set Rng = Wks.Range("A2")
       With CreateObject("MSXML2.XMLHTTP")
            .Open "GET", URL, False
             On Error Resume Next
            .Send
             On Error GoTo 0
             
            If .Status <> 200 Then
                MsgBox "Server Error: " & .Status & " - " & .StatusText
                Exit Sub
            End If
            
            Set HTMLdoc = CreateObject("htmlfile")
            HTMLdoc.Write .responseText
            HTMLdoc.Close
            
               Set Anchors = HTMLdoc.getElementsByTagName("A")
            
            For Each URL In Anchors
                If URL.className = "vip" Then
                    Rng.Offset(row, 0).Value = URL.href
                    row = row + 1
                End If
            Next URL
        End With
        
        Set HTMLdoc = Nothing
        
End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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