-
Notifications
You must be signed in to change notification settings - Fork 0
/
scrape2.rb
41 lines (28 loc) · 1.07 KB
/
scrape2.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# pass an url with a custom query and scrape the results into possible recipes
# for the user to store
# http://www.marmiton.org/recettes/recherche.aspx?aqt=fraise
#.recipe-card__title -> title
#.recipe-card__description -> description
#.recipe-card__duration__value -> duration
############################ SCRAPER ##########################################
require 'nokogiri'
require 'open-uri'
require_relative 'recipe'
class ScrapeService
attr_reader :doc
def initialize(searchkey)
@url = "http://www.aufeminin.com/recettes/recherche.aspx?type=all&aqt=#{searchkey}"
@doc = Nokogiri::HTML(open(@url, :read_timeout => 10).read)
end
# def scrapedobject
# holder = []
# @doc.search('').each do |card|
# title = card.search('.recipe-card__title').text
# descr = card.search('.recipe-card__description').text.strip
# duration = card.search('.recipe-card__duration__value').text
# holder << {name: title, description: descr, duration: duration}
# end
# return holder
# end
end
# p ScrapeService.new("chocolate").scrapedobject