Sub Manta()
For csk = 1 To 99
' Determine if a specific instance of IE is already open.
Set objShell = CreateObject("Shell.Application")
IE_count = objShell.Windows.Count
For x = 0 To (IE_count - 1)
On Error Resume Next ' sometimes more web pages are counted than are open
my_url = objShell.Windows(x).Document.Location
my_title = objShell.Windows(x).Document.Title
'You can use my_title of my_url, whichever you want
If my_url Like "https://www.manta.com" & "*" Then 'identify the existing web page
Set IE = objShell.Windows(x)
Exit For
Else
End If
Next
Set objCollection = IE.Document.getElementsByTagName("h2")
'MsgBox (objCollection.Length)
i = 0
While i < objCollection.Length
rowValue = ThisWorkbook.Sheets("Data").UsedRange.Rows.Count + 1
ThisWorkbook.Sheets("Data").Cells(rowValue, 1).Value = objCollection(i).innertext
ThisWorkbook.Sheets("Data").Cells(rowValue, 2).Value = "https://www.manta.com" & objCollection(i).Children(0).getAttribute("href")
i = i + 1
Wend
Set objCollection = IE.Document.getelementsbyclassname("ng-binding")
i = 0
While i < objCollection.Length
If i = 3 Then
objCollection(i).Click
' Wait while IE loading...
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
GoTo Line1
End If
i = i + 1
Wend
'ng-binding
Line1:
Application.Wait (Now + TimeValue("0:00:10"))
Next csk
End Sub
Comments
Post a Comment