8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/mls_standings/scrapper.rb', line 8
def self.scrape_teams
html = self.get_page
table = html.css('.standings_table tbody tr')
teams_hash_array = []
table.each do |team|
name = team.css('[data-title="Club"] .hide-on-mobile-inline').text
games_played = team.css('[data-title="Games Played"]').text
wins = team.css('[data-title="Wins"]').text
losses = team.css('[data-title="Losses"]').text
ties = team.css('[data-title="Ties"]').text
name.slice!('x - ')
name.slice!('s - ')
name.slice!('y - ')
team_hash = {:name => name, :games_played => games_played, :wins => wins, :losses => losses, :ties => ties}
teams_hash_array << team_hash
end
teams_hash_array.delete_at(0)
teams_hash_array.delete_at(12)
teams_hash_array
end
|