Class: SdEvents::Scraper
- Inherits:
-
Object
- Object
- SdEvents::Scraper
- Defined in:
- lib/sd_events/scraper.rb
Class Method Summary collapse
Class Method Details
.scrape ⇒ Object
3 4 5 |
# File 'lib/sd_events/scraper.rb', line 3 def self.scrape Nokogiri::HTML(open("https://www.sandiegoreader.com/events/#")) end |
.scrape_daypart(event_time) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/sd_events/scraper.rb', line 16 def self.scrape_daypart(event_time) self.scrape.css("div#body div#content.content div.daypart_#{event_time} .event_list").each do |event| event.css("tr").collect do |attribute| self.scrape_events(attribute) end end end |
.scrape_events(attribute) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/sd_events/scraper.rb', line 7 def self.scrape_events(attribute) new_event = SdEvents::Events.new new_event.name = attribute.css(".title").css("h4").text.strip new_event.venue = attribute.css(".title").css("h5").text.strip new_event.time = attribute.css("td.time").text.strip new_event.location = attribute.css("td.city").text.strip new_event.category = attribute.css("td.category").text.strip end |