Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 05-20-2024, 04:49 AM
Guessed's Avatar
Guessed Guessed is offline Help in trying to identify class string in each stage of URL Windows 10 Help in trying to identify class string in each stage of URL Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,187
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help in trying to identify class string in each stage of URL 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
Help in trying to identify class string in each stage of URL 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

Other Forums: Access Forums

All times are GMT -7. The time now is 10:00 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft