VBA pull URLs

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
840
Trying to pull all the URLs from an Airbnb search - any ideas on how to get this to work please?

VBA Code:
Sub GetHyperlinks_2()

    Dim XMLPage As New MSXML2.XMLHTTP60
    Dim htmlDoc As New MSHTML.HTMLDocument
    Dim URL As String
    Dim hLinks As MSHTML.IHTMLElementCollection
    Dim hLink As MSHTML.IHTMLElement
    Dim RowNum As Long: RowNum = 1
    Dim Last_Row As Long
    
    'Create URL and sent request
    URL = "https://www.airbnb.co.uk/s/Cardiff-city-centre--Cardiff/homes?adults=4&place_id=ChIJE5-LOrccbkgRzfLvM7ow5xU&checkin=2022-05-25&checkout=2022-05-26&tab_id=home_tab&refinement_paths%5B%5D=%2Fhomes&query=Cardiff%20city%20centre%2C%20Cardiff&flexible_trip_lengths%5B%5D=one_week&date_picker_type=calendar&source=structured_search_input_header&search_type=filter_change&ne_lat=51.490445308713475&ne_lng=-3.148398632049549&sw_lat=51.46676432836105&sw_lng=-3.204231494903553&zoom=14&search_by_map=true&room_types%5B%5D=Entire%20home%2Fapt"
    XMLPage.Open "GET", URL, False
    XMLPage.send
        
    'Get the source (code) of the webpage
    htmlDoc.body.innerHTML = XMLPage.responseText
    
    'Set reference to all hyperlinks in htmlDoc.body.innerHTML
    Set hLinks = htmlDoc.getElementsByTagName("A")
    
    'Loop through all hyperlink-tags . . .
    For Each hLink In hLinks
        
    If InStr(hLink, "/rooms") Then
    
    End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,223,897
Messages
6,175,270
Members
452,628
Latest member
dd2

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