Class: OnTapIbc::Scraper

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

Class Method Summary collapse

Class Method Details

.beer_detailsObject



27
28
29
# File 'lib/on_tap_ibc/scraper.rb', line 27

def self.beer_details
  self.scrape_core_beliefs
end

.scrape_core_beliefsObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/on_tap_ibc/scraper.rb', line 31

def self.scrape_core_beliefs
    beer_hashes = {}
    ["https://www.ithacabeer.com/ithaca-beer-core-beliefs","https://www.ithacabeer.com/ithaca-beer-random-acts"].each do |url|

    beers = Nokogiri::HTML(open(url))

    beers.css("div.col.sqs-col-10.span-10").each do |beer|
      beer_hashes["#{beer.css("div p.beerDetails").text.strip.upcase}"] = {
        style: beer.css("div p.beerDetails2").text.strip,
        long_desc: beer.css("div.html-block p")[0].text.strip,
        addl1: beer.css("div.html-block p").last.text.strip
      }
    end
  end
  beer_hashes
end

.scrape_menuObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/on_tap_ibc/scraper.rb', line 12

def self.scrape_menu
  beers = Nokogiri::HTML(open("https://www.ithacabeer.com/taproom-menu/#anchor-tap-list"))
  current_beers = []
  # Iterate through beer menu
  beers.css("div#block-yui_3_17_2_8_1508769314339_15193 div.menu-items div.menu-item").each do |beer|

    current_beers << {
      :name => beer.css("div.menu-item-title").text.strip,
      :abv => beer.css("span.menu-item-price-top").text.strip,
      :short_desc => beer.css("div.menu-item-description").text.strip
    }
  end
  current_beers
end

.updated_lastObject



6
7
8
9
10
# File 'lib/on_tap_ibc/scraper.rb', line 6

def self.updated_last
  doc = Nokogiri::HTML(open("https://www.ithacabeer.com/taproom-menu/#anchor-tap-list"))
  updated_last = doc.search("div#block-yui_3_17_2_8_1508769314339_15193 div.menu-section-title").text.strip
  updated_last
end