class CoffeeRoasters::Scraper

Public Instance Methods

scrape_roasters() click to toggle source
# File lib/coffee_roasters/scraper.rb, line 3
  def scrape_roasters
    doc = Nokogiri::HTML(open("https://www.thrillist.com/drink/nation/the-21-best-coffee-roasters-in-the-country"))

    section = doc.css("section.save-venue")
    section.each do |data|
# binding.pry
      roaster = CoffeeRoasters::Roaster.new

      roaster.name = data.css("h1 a.save-venue__link").text
      roaster.location = data.css("h2.save-venue__neighborhood").text
      roaster.bean = data.css("p.save-venue__description").text.split("\n")[0]
      roaster.details = data.css("p.save-venue__description").text.split("\n")[2]
      roaster.url = data.css("a.save-venue__link").attr("href").value

      roaster.save
    end
  
  end