Getting info from HTML page source code

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
FOr this purpose I recommend using MSHTML library. You just have to know the id of an element you are looking for.
Code:
    Sub Main()
        Dim xhr As MSXML2.XMLHTTP60
        Dim doc As MSHTML.HTMLDocument
        Dim spanElement as MSHTML.IHTMLElement
    
        Set xhr = New MSXML2.XMLHTTP60
    
        With xhr


            .Open "GET", "http://www.lazada.com.ph/samsung-qualcomm-quick-charger-30-wireless-charging-pad-forsamsung-s7s7-edge-black-5407464.html?spm=a2o4l.category-011126000000.0.0.N1i7oJ&ff=1&sc=Ebpi", False
            .send


            If .readyState = 4 And .Status = 200 Then
                Set doc = New MSHTML.HTMLDocument
                doc.body.innerHTML = .responseText
            Else
                MsgBox "Error" & vbNewLine & "Ready state: " & .readyState & _
                vbNewLine & "HTTP request status: " & .Status
            End If


        End With
    
        Set spanElement = doc.getElementById("special_price_box")
        Console.WriteLine(spanElement.innerText)
    End Sub
 
Upvote 0
Thanks Amadeuszi!

However i cant seem to output the information retrieved from the code.
I just know the basic excel VBA, if i want to study MSHTML library, where do you recommend that i look into?

Thanks again!
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,603
Members
449,089
Latest member
Motoracer88

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