mardi 1 décembre 2020

Questions for URL extraction from website using sub for excel

In excel sub, how do I get the actual URL text instead of HREF text for item(1) at the bottom? I'm using XML, but anything else is acceptable if it can get the job done.

Sub GetDogRace2()

Const URL2 = "https://fasttrack.grv.org.au/RaceField/ViewRaces/-83280?raceId=0"
Dim http As New XMLHTTP60, html As New HTMLDocument
Dim obj As HTMLHtmlElement
Dim obj2 As HTMLHtmlElement

Range("C1:I500") = ""
   
With http
    .Open "GET", URL2, False
    .send
    html.body.innerHTML = .responseText
End With

x = 2

For Each obj2 In html.getElementsByClassName("race-results-content")
    For Each obj In html.getElementsByTagName("tr")
        With obj.getElementsByTagName("td")
            If .Length Then Cells(x, 9) = Trim(Replace(.Item(1).innerHTML, " ", "")) '<-ThisOne
        End With
        x = x + 1
    
    Next obj
    x = x + 1
    
Next obj2
Set http = Nothing: Set html = Nothing: Set obj = Nothing
End Sub



Aucun commentaire:

Enregistrer un commentaire