Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $website = Invoke-WebRequest -Uri 'https://www.bold.dk/fodbold/danmark/superligaen/'
- ##################
- # Match OverView #
- ##################
- $teams = ($website.AllElements | where {$_.class -match 'team_name_container'}).innertext | select -Unique
- $games_played = (($website.AllElements | where {$_.class -match 'played kvut'}) | where {$_.total -ne ''}).total
- $games_won = (($website.AllElements | where {$_.class -match 'wins kvut'}) | where {$_.total -ne ''}).total
- $games_draw = (($website.AllElements | where {$_.class -match 'draws kvut'}) | where {$_.total -ne ''}).total
- $games_lost = (($website.AllElements | where {$_.class -match 'defeits kvut'}) | where {$_.total -ne ''}).total
- $goals = (($website.AllElements | where {$_.class -match 'goals'}) | where {$_.total -ne $null}).total -replace (' ','')
- $points = (($website.AllElements | where {$_.class -match 'points'}) | where {$_.total -ne $null -and $_.total -ne ''}).total
- $game_stats = New-Object -TypeName System.Collections.Generic.List[PsObject]
- for ($i = 0; $i -lt $teams.count;$i++)
- {
- $properties = [ordered]@{
- 'Team' = $teams[$i]
- 'Games_Played' = $games_played[$i]
- 'Games_Won' = $games_won[$i]
- 'Games_Draw' = $games_draw[$i]
- 'Games_Lost' = $games_lost[$i]
- 'Goals' = $goals[$i]
- 'Points' = $Points[$i]
- }
- $obj = New-Object -TypeName psobject -Property $properties
- $game_stats.Add($obj)
- }
- ##########
- # Match #
- ##########
- $dato = (($website.AllElements | where {$_.class -eq 'start small'} ).innerhtml)
- $tid = (((($website.AllElements | where {$_.class -eq 'time'} ).innerhtml)) -replace("tid","") | where {$_})
- $kampe = (((($website.AllElements | where {$_.class -eq 'name'} ).innerhtml)) -replace("kampe","") | where {$_})
- $scores = ((($website.AllElements | where {$_.class -eq 'score'} ).innerhtml))
- $Match_stats = New-Object -TypeName System.Collections.Generic.List[PsObject]
- for ($i=0;$i -lt $dato.count;$i++)
- {
- $properties = [ordered]@{
- 'Dato' = (($dato[$i] -split("/`">","")[0] -replace(" "," "))[-1] -split("</a>"))[0]
- 'Tid' = (($tid[$i] -split("/`">","")[0] -replace(" "," "))[-1] -split("</a>"))[0]
- 'Kamp' = (($kampe[$i] -split("/`">","")[0] -replace(" "," "))[-1] -split("</a>"))[0]
- 'Score' = (($scores[$i] -split("/`">","")[0] -replace(" "," "))[-1] -split("</a>"))[0]
- }
- $obj = New-Object -TypeName psobject -Property $properties
- $Match_stats.Add($obj)
- }
- $outfile = "$($env:USERPROFILE)\desktop\SuperLigaData.csv"
- $Matchfile = "$($env:USERPROFILE)\desktop\SuperLigaDataRunder.csv"
- $game_stats | Export-Csv -Path $outfile -Delimiter ';' -NoTypeInformation -Encoding UTF8 -Force
- $match_stats | Export-Csv -Path $MatchFile -Delimiter ';' -NoTypeInformation -Encoding UTF8 -Force
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement