• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA Macro to pull contact numbers of companies from a site in to excel.

Sir - Attaching the screenshot of the output in word doc, as i am unable to upload the excel sheet. Already you have fetched the data from Yellowpages.ca. which is populating in column "D,E,F" in excel sheet. Now can you help me to pull the data from "www.manta.com" and the result must populate in Column "G,H,I" in the excel sheet. Grateful if you can take reference to the earlier excel sheet result which you have attached on "Dec 02 2016".

Your help on this is highly appreciated.

Thanks
Kaarthick
 

Attachments

  • Sample Output.docx
    18.3 KB · Views: 3
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
 
Sir - Thanks for your revert back. I searched and it is not giving any results. Can you help me to pull the data from "www.411.ca" based on Company Name + Address 2. Do not want to consider "Address 1", as the provided address in the reference document attached does not match with "Search result address".

I am attaching the sample findings which i got from manual search & also the list of company names + addresses

Your help on this is highly appreciated.

Thanks
Kaarthick
 

Attachments

  • Sample Output1.docx
    19 KB · Views: 3
Sir - I got it while searching it Manually. I removed "JEROME" from the search. That was a typo in the file. You can take it as it is what is provided.,

Thanks
Kaarthick
 
OK sir. I wait for you. But it would be grateful if you can let know roughly how much days. Sorry as it's urgent asking you.


Thanks
Kaarthick
 
No guarantee. I'm volunteering my free time and my work and personal life takes precedence.

If it's urgent, hire someone for the job.
 
Back
Top