7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/surf_report/scraper.rb', line 7
def self.scrape_index_page
doc = Nokogiri::HTML(open("http://www.surfline.com/surf-forecasts/southern-california/south-los-angeles_2951"))
days = doc.css("div.day-slider-container")
report = {}
surf_days = [days.children[1], days.children[3], days.children[5]]
surf_days.each_with_index.map do |day, i|
{ :date => day.children.css("span")[0].text,
:forecast => day.css("strong").text,
:wave_size => day.css("h1").text,
:wave_description => day.children.css("span")[2].text,
:swell_direction => day.children.css("span")[3].text }
end
end
|