recipe_scraper 2.2.3 → 2.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff6587e185de963070fe2e3b9e8afdd909d4ee989d59535dcf7eb8d55da2e847
4
- data.tar.gz: a3d694b2b551ac1521586bf60cd21109607a8a48d893a7dce518b1bd90f63659
3
+ metadata.gz: a5458fafc667d8359af7beed1010e367a55089898fa800f5f34558afcc6d226f
4
+ data.tar.gz: ac88b77bd4d501ef2fdbbb4d8fc3f6c42ea776943a5175b8860b7f70a62f0b44
5
5
  SHA512:
6
- metadata.gz: ddcdbf5ea74b7842f04e714fe1eb491a2e98bb9575111e0b06c7bad5eecca196c987a410079076f7348cd446f69108d50dec2367977b2974ff47def52612f18a
7
- data.tar.gz: d4fc03e5d42d6dcbfbcf19162dad7d24030d31c53011ec94ddb56bfb338971dac63ce14b40d0757915d1ec4cb00f862f7faf26b7527456a58398b5c02e309d13
6
+ metadata.gz: 560d7d9a6daf95408f9f975e64b65083923effb408ed55257491802ff0c51ac33f80adb7deb922677e32fa0e54e7a8feb33805de53ef33a3db2e479a280f576c
7
+ data.tar.gz: 417f952652303404db89742d738fa285bfc1c956163ac7e543b83cb775c708646f1b4dcb1fb89d8928d79523a3cbdc7e60e88d856cb370c4b8b2b7c21fa6117d
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "marmiton_crawler"
3
+ require 'bundler/setup'
4
+ require 'recipe_scraper'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "marmiton_crawler"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start
@@ -7,7 +7,7 @@ require 'recipe_scraper/version'
7
7
  module RecipeScraper
8
8
  # represent a recipe fetched from an Url
9
9
  class Recipe
10
- attr_reader :title, :preptime, :cooktime, :ingredients, :steps, :image
10
+ attr_reader :title, :preptime, :cooktime, :ingredients, :steps, :image, :nb_of_persons
11
11
 
12
12
  MARMITON_HOST = { desktop: 'marmiton.org/', mobile: 'm.marmiton.org/' }.freeze
13
13
  G750_HOST = { desktop: '750g.com' }.freeze
@@ -98,6 +98,9 @@ module RecipeScraper
98
98
  page = Nokogiri::HTML(open(url).read)
99
99
  @title = page.css('h1').text
100
100
 
101
+ # get persons
102
+ @nb_of_persons = page.css('div.recipe-infos__quantity > span.recipe-infos__quantity__value').text.to_i
103
+
101
104
  # get times
102
105
  @preptime = page.css('div.recipe-infos__timmings__preparation > span.recipe-infos__timmings__value').text.to_i
103
106
  @cooktime = page.css('div.recipe-infos__timmings__cooking > span.recipe-infos__timmings__value').text.to_i
@@ -120,7 +123,6 @@ module RecipeScraper
120
123
  rescue StandardError
121
124
  NoMethodError
122
125
  end
123
-
124
126
  else
125
127
  raise ArgumentError, "Instantiation cancelled (ulr not from #{MARMITON_HOST})."
126
128
  end
@@ -134,6 +136,12 @@ module RecipeScraper
134
136
  page = Nokogiri::HTML(open(url).read)
135
137
  @title = page.css('h1.c-article__title').text
136
138
 
139
+ # get persons
140
+ nb_of_persons_matches = page.css('h2.u-title-section').text.match(/(\d{1,5})/)
141
+ if !nb_of_persons_matches.nil? && nb_of_persons_matches[1]
142
+ @nb_of_persons = nb_of_persons_matches[1].to_i
143
+ end
144
+
137
145
  # get times
138
146
  @preptime = sanitize(page.css('ul.c-recipe-summary > li.c-recipe-summary__rating[title="Temps de préparation"]').text).to_i
139
147
  @cooktime = sanitize(page.css('ul.c-recipe-summary > li.c-recipe-summary__rating[title="Temps de cuisson"]').text).to_i
@@ -150,6 +158,7 @@ module RecipeScraper
150
158
 
151
159
  # get image
152
160
  css_image = 'div.swiper-wrapper img.photo'
161
+
153
162
  begin
154
163
  @image = page.css(css_image).attr('src').to_s
155
164
  rescue NoMethodError => e
@@ -168,6 +177,8 @@ module RecipeScraper
168
177
  page = Nokogiri::HTML(open(url).read)
169
178
  @title = page.css('h1').text
170
179
 
180
+ # get persons
181
+ @nb_of_persons = page.css('#ContentPlaceHolder_LblRecetteNombre').text.to_i
171
182
  # get times
172
183
  @preptime = page.css('#ContentPlaceHolder_LblRecetteTempsPrepa').text.to_i
173
184
  @cooktime = page.css('#ContentPlaceHolder_LblRecetteTempsCuisson').text.to_i
@@ -1,3 +1,3 @@
1
1
  module RecipeScraper
2
- VERSION = '2.2.3'.freeze
2
+ VERSION = '2.2.4'.freeze
3
3
  end
@@ -1,27 +1,26 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'recipe_scraper/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "recipe_scraper"
6
+ spec.name = 'recipe_scraper'
8
7
  spec.version = RecipeScraper::VERSION
9
- spec.authors = ["madeindjs"]
10
- spec.email = ["madeindjs@gmail.com"]
8
+ spec.authors = ['Alexandre Rousseau']
9
+ spec.email = ['contact@rousseau-alexandre.fr']
11
10
 
12
- spec.summary = %q{A web scrawler to get a Marmiton's, cuisineaz or 750g recipe}
11
+ spec.summary = 'A web scraper to get recipe data just by its web url'
13
12
  # spec.description = %q{TODO: Write a longer description or delete this line.}
14
- spec.homepage = "https://github.com/madeindjs/recipe_scraper"
15
- spec.license = "MIT"
13
+ spec.homepage = 'https://github.com/madeindjs/recipe_scraper'
14
+ spec.license = 'MIT'
16
15
 
17
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
17
+ spec.bindir = 'exe'
19
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
21
20
 
22
- spec.add_development_dependency "bundler", "~> 1.11"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "rspec", "~> 3.0"
25
-
26
- spec.add_dependency "nokogiri"
21
+ spec.add_development_dependency 'bundler', '~> 1.11'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rspec', '~> 3.0'
24
+
25
+ spec.add_dependency 'nokogiri'
27
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recipe_scraper
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.2.4
5
5
  platform: ruby
6
6
  authors:
7
- - madeindjs
7
+ - Alexandre Rousseau
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-06 00:00:00.000000000 Z
11
+ date: 2018-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -68,7 +68,7 @@ dependencies:
68
68
  version: '0'
69
69
  description:
70
70
  email:
71
- - madeindjs@gmail.com
71
+ - contact@rousseau-alexandre.fr
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
@@ -107,8 +107,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.7.7
110
+ rubygems_version: 2.7.8
111
111
  signing_key:
112
112
  specification_version: 4
113
- summary: A web scrawler to get a Marmiton's, cuisineaz or 750g recipe
113
+ summary: A web scraper to get recipe data just by its web url
114
114
  test_files: []