Our training courses

Other training resources

Our training venues

Why we are different

Details for Jonathanvk

Jonathanvk has participated in the following threads:

Added by Jonathanvk on 13 Dec 2017 at 08:25

Hi, I have one question. Partly by using your super useful vide's I started trying extracting data from websites to excel. There is one thing though that just keeps failing. Here is an example of the code written. The line:

Debug.print Classnames.length

keeps returning 0, whatever searchtype I use, classname, tagname, id. Could you find any incorrect use of code in here?

Thanks in advance for your answer.

Jonathan

Const HappyEmpURL As String = "https://happyemployees.nle.nl/"

Sub GetDataFromWebsite()

Dim XMLReq As New MSXML2.XMLHTTP60
Dim HTMLDoc As New MSHTML.HTMLDocument
Dim Article1 As MSHTML.IHTMLElement
Dim Classnames As MSHTML.IHTMLElementCollection

XMLReq.Open "GET", HappyEmpURL, False
XMLReq.send

If XMLReq.Status <> 200 Then
    MsgBox "Problem" & vbNewLine & XMLReq.Status & "-" & XMLReq.statusText
    Exit Sub
End If

HTMLDoc.Body.innerHTML = XMLReq.responseText
Set Classnames = HTMLDoc.getElementsByClassName("mx-layoutcontainer-center mx-scrollcontainer-center ")
Debug.Print Classnames.Length
For Each Article1 In Classnames
Article1.getElementsByid ("159b6aef-dbc3-5b23-a735-cf99f8341771-1")
Debug.Print Article1.getAttribute("href"), Article1.innerText, Article1.className
Next Article1

End Sub

Head office

Kingsmoor House

Railway Street

GLOSSOP

SK13 2AA

London

Landmark Offices

99 Bishopsgate

LONDON

EC2M 3XD

Manchester

Holiday Inn

25 Aytoun Street

MANCHESTER

M1 3AE

© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.

End of small page here
Please be aware that our website uses cookies!
I'm OK with this Tell me more ...