shahin
Active Member
Hi there hope you all are doing good. After writing a script to parse documents from a web page I could see that it only grabs the first element of each category and can't reach out for the elements partitioned by <br> tag within the same category. Phone number, fax etc are in first category within "p" tag but can't get it anyway. Here is what I tried with. Hope somebody will show me any way to succeed. By the way, i tried with two type of calling and i attached both.
Code:
Sub RestData()
Dim http As New MSXML2.XMLHTTP60
Dim html As New HTMLDocument
Dim ele As Object, post As Object
With CreateObject("MSXML2.serverXMLHTTP")
.Open "GET", "http://www.austrade.gov.au/SupplierDetails.aspx?ORGID=ORG0120000508&folderid=1736", False
.send
html.body.innerHTML = .responseText
End With
Set ele = html.getElementsByClassName("contact-details block dark")(0).getElementsByTagName("p")
For Each post In ele
x = x + 1
Cells(x, 1) = post.innerText
Next post
' Set ele = html.getElementsByClassName("contact-details block dark")
' For Each post In ele
' Set docs = post.getElementsByTagName("p")(0)
' x = x + 1
' Cells(x, 1) = docs.innerText
' Next post
Set html = Nothing: Set ele = Nothing: Set docs = Nothing
End Sub