class Scraper

Constants

USER_AGENT

Used in openuri requests to prevent 403 Coppied from chrome on windows 10

Public Class Methods

scrape_day_details(full_url) click to toggle source
# File lib/scraper.rb, line 23
def self.scrape_day_details(full_url)
        doc = Nokogiri::HTML(open(full_url, 'User-Agent'=>USER_AGENT))
        details = {}
        doc.css(".post-content > p").each do |item|
                if !item.text.strip.empty?
                        details[:summary] = item.text.gsub("\u00A0", ' ')
                        break
                end
        end
        details
end
scrape_month(full_url) click to toggle source
# File lib/scraper.rb, line 8
def self.scrape_month(full_url)
        doc = Nokogiri::HTML(open(full_url, 'User-Agent'=>USER_AGENT))
        days_of_month = []
        tiles = doc.css('div.et_pb_blurb_container')
        tiles.each do |tile|
                day_of_month = {}
                day_of_month[:title] = tile.css('h4').text
                day_of_month[:days] = tile.css('li a').collect do |day_link|
                        {name: day_link.text, url: day_link.attr('href')}
                end
                days_of_month << day_of_month
        end
        days_of_month
end