Skip to content

Commit

Permalink
Working version, simplified from master. No frakking around. The only…
Browse files Browse the repository at this point in the history
… thing missing is the conversion to a date format and them generate the ical
  • Loading branch information
rogeriopvl committed Oct 6, 2010
1 parent 44af370 commit 523e56a
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions script.rb
Expand Up @@ -8,16 +8,21 @@ def get_uefa_games
# need to change this URL when the group fase is over
uefa_group_url="http://desporto.sapo.pt/futebol/liga_europa/resultados/479"

events = []

uefa_content = open(uefa_group_url).read
doc = Hpricot(uefa_content)

res = doc.search("tr")
res.each do |e|
td = e.search("td")
next if td.length < 1
sp = td[2].at("span.clube1 a").inner_html
puts "Sporting joga em casa: #{td[0].inner_html} - #{td[1].inner_html}" if sp.index("Sporting")
next if td[2].nil?
span = td[2].at("span.clube1 a")
next if span.nil?
events << "#{td[0].inner_html}" if span.inner_html.index("Sporting")
end
events
end

# fetches all games home games from liga sagres
Expand All @@ -26,6 +31,8 @@ def get_liga_games
# apparently this wont need to be changed
liga_url = "http://desporto.sapo.pt/futebol/primeira_liga/calendario/";

events = []

liga_content = open(liga_url).read
doc = Hpricot(liga_content)

Expand All @@ -34,11 +41,18 @@ def get_liga_games
t.search("tr").each do |tr|
td = tr.search("td")
next if td.length < 1
sp = td[2].at("span.clube1 a").inner_html
puts "Sporting joga em casa: #{td[0].inner_html} - #{td[1].inner_html}" if sp.index("Sporting")
next if td[2].nil?
span = td[2].at("span.clube1 a")
next if span.nil?
events << "#{td[0].inner_html}" if span.inner_html.index("Sporting") && td[0].inner_html.length > 0
end
end
events
end

get_uefa_games
evs = get_uefa_games << get_liga_games

evs.each do |ev|
puts Date.strptime(ev, "%d %m")
end

0 comments on commit 523e56a

Please sign in to comment.