Grabbing Website data using HTML with VBA Macro

kodydale

New Member
Joined
Aug 25, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to create a macro (first one), where I can hit a button and it automatically grabs a piece of data from a site for me.

Here is the site: Browse Inventory | Ryder Used Truck Sales

The piece of data I am trying to grab is the results number after the filter at the mid top left. Eventually, I would add the website filters to get the numbers for each specialized category. Thank you for your help in advance.

Thanks
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
1661442742393.png
This is how I would want it to be set up
 
Upvote 0
Sub ScrapeWebData()
Dim HTTPreq As New MSXML2.XMLHTTP60
Dim html As HTMLDocument, url As String, response As String

url = "Browse Inventory | Ryder Used Truck Sales"

'send http request to url
With HTTPreq
.Open "GET", url, False
.send
End With

response = HTTPreq.responseText

Debug.Print response

'Read response html document
sethtml = CreateObject("htmlfile")
html.body.innerHTML = response
r = 1
For Each divElement In html.getElementById("totalrescount")
r = r + 1
Set divCollection = divElement.all
For Each element In divCollection
Next element
Next divElement

End Sub


This is my code so far
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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