Extracting Links

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Andy

This scrappy code works in part.
Rich (BB code):
Option Explicit
 
Sub GetStatsLinks()
Dim IE As Object
Dim doc As Object
Dim divs As Object
Dim lnks As Object
Dim lnk As Object
Dim cls
Dim rng As Range
 
    Set IE = CreateObject("InternetExplorer.Application")
 
    Set rng = Range("A1")
 
    With IE
 
        .Visible = True
 
        .navigate "http://msn.foxsports.com/foxsoccer/eredivisie/scores?week=1&timeframe=1"
 
        Do Until .ReadyState = 4
            DoEvents
        Loop
 
        Set doc = IE.Document
 
        Set divs = doc.getElementsByTagName("DIV")
 
        For Each dv In divs
 
            If dv.className = "fsiScoresBoxscoreLinksWrapper" Then
 
                Set lnks = dv.getElementsByTagName("A")
 
                For Each lnk In lnks
 
                    cls = lnk.className
 
                    If cls = "fsiLeagueDataLink" Then
 
                        rng.Offset(, 1).Value = lnk.href
 
                        rng.Value = dv.outerText
 
                        Set rng = rng.Offset(1)
 
                    End If
 
                Next lnk
            End If
        Next dv
 
    End With
 
    Set IE = Nothing
 
End Sub
I also tried to get the teams, and I managed to, but I couldn't combine the two.

The divs on the page seem to be structured well - the DIVs for the team names all have the same class, as do the stats.

Couldn't work out how to link them properly though as they all come under another 'super' parent DIV.
 
Upvote 0
Or this after the Set doc line:
Code:
    Dim links As String
    links = ""
    For Each link In doc.links
        If link.innerText = "Match Stats" Then links = links & link.href & vbNewLine
    Next
    MsgBox links
 
Upvote 0
Hi guys,

Firstly I wanted to say thanks for having a stab at this, it gives me a great starting point. I'll have a crack at building this and if I manage to, I'll post up my working code for others to use.

Cheers,

Andy
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,357
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top