Class: OrlandoEvents::Scraper

Inherits:
Object
  • Object
show all
Defined in:
lib/orlando_events/scraper.rb

Class Method Summary collapse

Class Method Details

.scrape_dates(date_page) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/orlando_events/scraper.rb', line 9

def self.scrape_dates(date_page)
  months = []
  doc = Nokogiri::HTML(open(date_page))
  doc.css("div#left_nav li").each do |month|
    link = month.css("a").map {|link| link['href']}
    month_info = {:name => month.css("a").text.gsub("               ", ""), :month_url => "http://www.downtownorlando.com/future#{link[0]}"}
    months << month_info
  end
  months
end

.scrape_event_info(month_page) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/orlando_events/scraper.rb', line 20

def self.scrape_event_info(month_page)
  doc = Nokogiri::HTML(open(month_page))
  events = []
  doc.css(".view-content .row-fluid").each do |event|
    date = event.css("strong").text.gsub("\n    ","") #gets date
    event_detail = {:date => date.gsub("            ",""), :event_title => event.css(".event_title a").text, :event_location => event.css(".location").text}
    events << event_detail

  end
  # binding.pry
  events
end

.scrape_eventsObject



3
4
5
6
7
# File 'lib/orlando_events/scraper.rb', line 3

def self.scrape_events
  events = []
  events << self.scrape_dates
  events
end