Sir- The previous logic i am embedding here. Grateful if you can also populate the data from"
www.manta.com" in to the same logic...
Sub Test()
Dim ie As Object, ieDoc As Object
Dim i As Integer
Dim cName As String, tagcName As String, tagPhone As String
Dim istr As String
Dim cel As Range
Dim x As Variant
Set ie = CreateObject("InternetExplorer.Application")
For Each cel In Range("A2:A" & Cells(Rows.Count, 1).End(xlUp).Row)
If cel.Offset(, 3) = "" Then
cName = Replace(cel.Value, " ", "+")
Url = "
http://www.yellowpages.ca/search/si/1/" & cName & "/" & cel.Offset(, 2).Value
ie.navigate Url
Do Until (ie.readyState = 4 And Not ie.Busy)
DoEvents
Loop
Set ieDoc = ie.Document
istr = ieDoc.All(0).innerHTML
If htmlCheck(istr) Then
cel.Offset(, 3).Value = "Not Found"
GoTo Skip2:
End If
On Error GoTo Skip:
tagcName = ieDoc.getElementsByClassName("listing__name--link jsListingName")(0).innerText
cel.Offset(, 5).Value = tagcName
Skip:
Resume NextStep:
NextStep:
On Error GoTo Skip1:
tagLink = ieDoc.getElementsByClassName("mlr__item__cta")(0).href
x = Split(tagLink, "?")
cel.Offset(, 4).Value = x(UBound(x))
Skip1:
Resume NextStep1:
NextStep1:
On Error GoTo Skip2:
tagPhone = ieDoc.getElementsByClassName("mlr__submenu__item")(0).innerText
cel.Offset(, 3).Value = tagPhone
End If
Skip2:
Next cel
Set ie = Nothing
'MsgBox "Process Complete"
End Sub
Public Function htmlCheck(pStr As String) As Boolean
Dim regex As Object
Set regex = CreateObject("VBScript.RegExp")
With regex
.Pattern = "\b(We didn’t find any business listings matching)\b"
End With
htmlCheck = regex.Test(pStr)
End Function