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