shahin
Active Member
Running my vba script I can see that it can't reach the target page where i would like to extract the different names from. Clearly I have messed somewhere up in my code but can't find out. Hope somebody will help me find out where i'm making mistakes. Thanks. Here is the code:
Code:
Sub Getmethod()
Dim http As New MSXML2.ServerXMLHTTP, html As New HTMLDocument
Dim docs, doc, ele As Object
Dim StrData As String
StrData = "what=Plumbers/where=All+States"
With http
.Open "GET", "http://www.yellowpages.co.za/search/" & StrData, False
.setRequestHeader "Content-Type", "text/xml"
.send
html.body.innerHTML = .responseText
End With
Set docs = html.getElementsByClassName("resultName")
For Each doc In docs
Set ele = doc.getElementsByTagName("a")(0)
x = x + 1
Cells(x, 1) = ele.innerText
Next doc
Set html = Nothing: Set docs = Nothing: Set doc = Nothing: Set ele = Nothing
End Sub
Last edited: