Advertisement
Guest User

SuperLiga

a guest
Oct 22nd, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ###################################
  2. # Skrevet af Lasse M N 2017-10-23 #
  3. ###################################
  4.  
  5. $website = Invoke-WebRequest -Uri 'https://www.bold.dk/fodbold/danmark/superligaen/'
  6.  
  7. $teams = ($website.AllElements | where {$_.class -match 'team_name_container'}).innerhtml -replace("<div>","") -replace("</div>","")
  8. $games_played = ($website.AllElements | where {$_.class -match 'played kvut'}).innerhtml -replace("<div>","") -replace("</div>","")
  9. $games_won = ($website.AllElements | where {$_.class -match 'wins kvut'}).innerhtml -replace("<div>","") -replace("</div>","")
  10. $games_draw = ($website.AllElements | where {$_.class -match 'draws kvut'}).innerhtml -replace("<div>","") -replace("</div>","")
  11. $games_lost = ($website.AllElements | where {$_.class -match 'defeits kvut'}).innerhtml -replace("<div>","") -replace("</div>","")
  12. $goals = ($website.AllElements | where {$_.class -match 'goals'}).innerhtml -replace("<div>","") -replace("</div>","")
  13. $points = ($website.AllElements | where {$_.class -match 'points'}).innerhtml -replace("<div>","") -replace("</div>","")
  14.  
  15. $game_stats = @()
  16.  
  17. for ($i = 0; $i -lt $teams.count)
  18. {
  19.     $team_objects = New-Object -TypeName psobject
  20.     $team_objects | Add-Member –MemberType NoteProperty –Name Team –Value $teams[$i]
  21.     $team_objects | Add-Member –MemberType NoteProperty –Name Games_Played –Value $games_played[$i]
  22.     $team_objects | Add-Member –MemberType NoteProperty –Name Games_Won –Value $games_won[$i]
  23.     $team_objects | Add-Member –MemberType NoteProperty –Name Games_Draw –Value $games_draw[$i]
  24.     $team_objects | Add-Member –MemberType NoteProperty –Name Games_Lost –Value $games_lost[$i]
  25.     $team_objects | Add-Member –MemberType NoteProperty –Name Goals –Value $goals[$i+1]
  26.     $team_objects | Add-Member –MemberType NoteProperty –Name Points –Value $Points[$i+1]
  27.  
  28.     $game_stats += $team_objects
  29.     $i++
  30. }
  31.  
  32. $outfile = "$($env:USERPROFILE)\desktop\$((Get-Date).GetDateTimeFormats()[21] -replace(":",".")) SuperLigaData.txt"
  33.  
  34. if (!(Test-Path -Path $outfile))
  35. {
  36.     New-Item -Path $outfile -ItemType File
  37. }
  38.  
  39. Foreach ($item in $game_stats)
  40. {
  41.     $item | Out-File -Append -FilePath $outfile -Force
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement