![]() |
|
#2
|
||||
|
||||
|
I'm not sure what you are asking on the levels question but this variation returns the values you found along the way so you can derive the subsequent URLs. I suspect getting an empty string back will answer your levels question.
Code:
Sub GetClass()
Dim url1 As String, url2 As String, url3 As String, url4 As String
Dim toSearch1 As String, toSearch2 As String, toSearch3 As String, toSearch4 As String
Dim HTMLDoc As New HTMLDocument
'URL levels
url1 = "https://locations.bojangles.com/"
'Text to search in each level
toSearch1 = "Alabama"
toSearch2 = "Huntsville"
toSearch3 = "South Memorial Pkwy"
toSearch4 = "11375 South Memorial Pkwy"
'Print className for each level
url2 = url1 & LoopElements(url1, toSearch1, "Level1")
url3 = url1 & LoopElements(url2, toSearch2, "Level2")
url4 = url1 & LoopElements(url3, toSearch3, "Level3")
url4 = Replace(url4, "../", "")
Call LoopElements(url4, toSearch4, "Level4")
End Sub
Function LoopElements(url As String, toSearch As String, level As String) As String
Dim HTMLDoc As New HTMLDocument
Dim links As Object
Dim i As Integer
Debug.Print "Now searching: " & url, toSearch, level
With New ServerXMLHTTP60
.Open "Get", url, False
.send
HTMLDoc.body.innerHTML = .responseText
End With
Set links = HTMLDoc.body.getElementsByTagName("a")
With links
For i = 0 To .Length - 1
If .Item(i).innerText Like "*" & toSearch & "*" Then
Debug.Print "", .Item(i), .Item(i).innerText
Debug.Print "", level & " ClassName: " & .Item(i).className
LoopElements = Split(.Item(i), ":")(1)
End If
Next i
End With
End Function
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Turn off an Initialized Class
|
ilcaa72 | Word VBA | 3 | 05-01-2017 07:13 PM |
| Returned to the stage to enter a license code product | Rahayu Sinuraya | Office | 0 | 01-09-2017 03:28 AM |
Way to search for a string in text file, pull out everything until another string?
|
omahadivision | Excel Programming | 12 | 11-23-2013 12:10 PM |
| Evernote--Class Notes | markg2 | Outlook | 0 | 05-10-2012 05:50 PM |
| Word forces a white border at the Print stage | niceguyjin | Word | 1 | 08-13-2011 01:46 AM |