Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###################################
- # Skrevet af Lasse M N 2017-10-23 #
- ###################################
- $website = Invoke-WebRequest -Uri 'https://www.bold.dk/fodbold/danmark/superligaen/'
- $teams = ($website.AllElements | where {$_.class -match 'team_name_container'}).innerhtml -replace("<div>","") -replace("</div>","")
- $games_played = ($website.AllElements | where {$_.class -match 'played kvut'}).innerhtml -replace("<div>","") -replace("</div>","")
- $games_won = ($website.AllElements | where {$_.class -match 'wins kvut'}).innerhtml -replace("<div>","") -replace("</div>","")
- $games_draw = ($website.AllElements | where {$_.class -match 'draws kvut'}).innerhtml -replace("<div>","") -replace("</div>","")
- $games_lost = ($website.AllElements | where {$_.class -match 'defeits kvut'}).innerhtml -replace("<div>","") -replace("</div>","")
- $goals = ($website.AllElements | where {$_.class -match 'goals'}).innerhtml -replace("<div>","") -replace("</div>","")
- $points = ($website.AllElements | where {$_.class -match 'points'}).innerhtml -replace("<div>","") -replace("</div>","")
- $game_stats = @()
- for ($i = 0; $i -lt $teams.count)
- {
- $team_objects = New-Object -TypeName psobject
- $team_objects | Add-Member –MemberType NoteProperty –Name Team –Value $teams[$i]
- $team_objects | Add-Member –MemberType NoteProperty –Name Games_Played –Value $games_played[$i]
- $team_objects | Add-Member –MemberType NoteProperty –Name Games_Won –Value $games_won[$i]
- $team_objects | Add-Member –MemberType NoteProperty –Name Games_Draw –Value $games_draw[$i]
- $team_objects | Add-Member –MemberType NoteProperty –Name Games_Lost –Value $games_lost[$i]
- $team_objects | Add-Member –MemberType NoteProperty –Name Goals –Value $goals[$i+1]
- $team_objects | Add-Member –MemberType NoteProperty –Name Points –Value $Points[$i+1]
- $game_stats += $team_objects
- $i++
- }
- $outfile = "$($env:USERPROFILE)\desktop\$((Get-Date).GetDateTimeFormats()[21] -replace(":",".")) SuperLigaData.txt"
- if (!(Test-Path -Path $outfile))
- {
- New-Item -Path $outfile -ItemType File
- }
- Foreach ($item in $game_stats)
- {
- $item | Out-File -Append -FilePath $outfile -Force
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement