VBA get div class data from webpage into excel

richtiger1

New Member
Joined
Jun 8, 2016
Messages
4
Even tho there as numurous of posts about this subject, I just can't get it done with a specific webpage. I'm trying to get the price of the article from the following webpage;
https://www.bol.com/nl/p/epson-expression-home-xp-235-all-in-one-printer/9200000049776302/
The info is in the div class named "fluid-grid__item".
I've already tried several ways, but just can't get it done. I'm quote known with HTML as well as VBA.
I've tried it so far with a MSXML2.XMLHTTP object to get the responstext of the webpage. The way of using WINHTTP.WinHTTPRequest.5.1 doesn't work eather. It will give an error with the "send" line - probably due the VPN connection.

Hope anyone can help me retrieve the info into excel.
Thanks in advance, Richtiger1
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Hi Richtiger!

Did you try something with HTML libraries and Internet Control libraries?
Something like

Code:
Set prcs = IE.Document.getElementById("main_block").getElementsByTagName("span")

For Each prc In prcs
        If (prc .getAttribute("className") = "product-price-bol price-big") Then
...
 
Upvote 0
Hi Richtiger!

Did you try something with HTML libraries and Internet Control libraries?
Something like

Code:
Set prcs = IE.Document.getElementById("main_block").getElementsByTagName("span")

For Each prc In prcs
        If (prc .getAttribute("className") = "product-price-bol price-big") Then
...

Ok... I guess i got a complete blackout. According to debug.print all classNames are "null" which must be something I'm doing really wrong.

What I've got (shortened) at this point is;

Code:
Set IE = New InternetExplorer    With IE
        .navigate "https://www.bol.com/nl/p/epson-expression-home-xp-235-all-in-one-printer/9200000049776302/"
        .Visible = False
        While .Busy Or .readyState <> READYSTATE_COMPLETE
           DoEvents
        Wend
        Set objHTML = .document
        DoEvents
    End With


Set prcs = IE.document.getElementById("main_block").getElementsByTagName("span")


For Each prc In prcs
Debug.Print (prc.getAttribute("classname"))


        If prc.getAttribute("className") = "product-price-bol price-big" Then Sheets(1).Range("A1") = x
Next prc
 
Upvote 0
ok, define IE as InternetExplorerMedium (not just InternetExplorer), prcs as IHTMLElementCollection (not just HTMLElementCollection) and prc as IHTMLElement (not just HTMLElement)
 
Upvote 0
Oh, and anyway I don't know what does calling a method "getattribute" into a print function do. If you know you've the right span with the right attribute you should put inside the "If" "prc.innerText"
 
Upvote 0
Oh, and anyway I don't know what does calling a method "getattribute" into a print function do. If you know you've the right span with the right attribute you should put inside the "If" "prc.innerText"

InternetExplorerMedium did gave errors, but defining the rest worked liked a charm!
Thanks!
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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