recipe_scraper 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad21bfeb82ade7c69ec91efb87659fbf0f43ead3
4
- data.tar.gz: f6a3a569c869c41213fca36f213fbb5efc47b48a
3
+ metadata.gz: e025c453bfd951c2b67abaf3d27a269af4d6dd00
4
+ data.tar.gz: f32ea1856cdc9caea8caed07153d76450dc94ca3
5
5
  SHA512:
6
- metadata.gz: b1c6991149659d6003ac2955340ed71563fc8c8e56609bb3442f82bdf56c8758017e668c33411998bd68bf54436eb3bed123cdd43ae77d62ef0873c9dd59971e
7
- data.tar.gz: e649b6171fce236dd2829c26aa75d8d445945266fe6c527bd468abce1edb33a198f0b5f35371bf7f13ee9d101f192a2ac317cb38381f0aeadee00e3c4ba991fa
6
+ metadata.gz: 6d2ab974e447358d9f2f90476caea4f3cee4236c17a5dceef9e3a470ad89653c121297b725fe646f71a7dc3bbc54750a36fe90dd076952d52b4fbf704158aff4
7
+ data.tar.gz: 2aaff08dbb6c1a794d4e0d9e9ff009832802dca967d104f1b786d42e5ed90e0f6840ecf5d7071e743d8434b14989a10b7340d0069fc8923bb18e50926e250280
@@ -18,7 +18,7 @@ module RecipeScraper
18
18
  CUISINEAZ_HOST = {desktop: 'http://www.cuisineaz.com/'}
19
19
 
20
20
 
21
-
21
+
22
22
  # Instanciate a Recipe object with data crawled from an url
23
23
  #
24
24
  # @param url [String] representing an url from Marmiton or 750g website
@@ -34,7 +34,7 @@ module RecipeScraper
34
34
  fetch_from_cuisineaz url
35
35
 
36
36
  else
37
- raise ArgumentError, "Instantiation cancelled (Host not supported)."
37
+ raise ArgumentError, "Instantiation cancelled (Host not supported)."
38
38
  end
39
39
  end
40
40
 
@@ -68,7 +68,7 @@ module RecipeScraper
68
68
  # @param text [String] a text to sanitize
69
69
  # @return [String] as text corrected formated
70
70
  def sanitize text
71
- [' ', '\r\n', "\r\n", "\n", "\r"].each { |text_to_remove|
71
+ [' ', '\r\n', "\r\n", "\n", "\r", "\t", / ^/, / $+/, /^  /, /^ /].each { |text_to_remove|
72
72
  text.gsub!(text_to_remove,'')
73
73
  }
74
74
  return text
@@ -111,29 +111,30 @@ module RecipeScraper
111
111
  url.gsub! MARMITON_HOST[:mobile], MARMITON_HOST[:desktop]
112
112
 
113
113
  page = Nokogiri::HTML(open(url).read)
114
- @title = page.css('h1.m_title span.item span.fn').text
114
+ @title = page.css('h1').text
115
115
 
116
116
 
117
117
  # get times
118
- @preptime = page.css('p.m_content_recette_info span.preptime').text.to_i
119
- @cooktime = page.css('p.m_content_recette_info span.cooktime').text.to_i
118
+ @preptime = page.css('div.recipe-infos__timmings__preparation > span.recipe-infos__timmings__value').text.to_i
119
+ @cooktime = page.css('div.recipe-infos__timmings__cooking > span.recipe-infos__timmings__value').text.to_i
120
120
 
121
121
  # get ingredients
122
- ingredients_text = page.css('div.m_content_recette_ingredients').text
123
- @ingredients = sanitize(ingredients_text).split '- '
124
- @ingredients.delete_at(0) # to delete the first `Ingrédients (pour 2 personnes) :`
122
+ @ingredients = []
123
+ ingredients_text = page.css('ul.recipe-ingredients__list li.recipe-ingredients__list__item').each do |ingredient_tag|
124
+ @ingredients << sanitize(ingredient_tag.text)
125
+ end
125
126
 
126
127
  # get steps
127
- steps_text = page.css('div.m_content_recette_todo').text
128
- @steps = sanitize(steps_text).split '. '
129
- @steps.delete_at(0) # to delete the first `Ingrédients (pour 2 personnes) :`
128
+ @steps = []
129
+ steps_text = page.css('ol.recipe-preparation__list').each do |step_tag|
130
+ @steps << sanitize(step_tag.text)
131
+ end
130
132
 
131
133
  # get image
132
- @image = page.css('a.m_content_recette_illu img.m_pinitimage').attr('src').to_s
133
-
134
+ @image = page.css('#af-diapo-desktop-0_img').attr('src').to_s rescue NoMethodError
134
135
 
135
136
  else
136
- raise ArgumentError, "Instantiation cancelled (ulr not from #{MARMITON_HOST})."
137
+ raise ArgumentError, "Instantiation cancelled (ulr not from #{MARMITON_HOST})."
137
138
  end
138
139
  end
139
140
 
@@ -147,8 +148,8 @@ module RecipeScraper
147
148
  @title = page.css('h1.c-article__title').text
148
149
 
149
150
  # get times
150
- @preptime = page.css('ul.c-recipe-summary li time[itemprop=prepTime]').text.to_i
151
- @cooktime = page.css('ul.c-recipe-summary li time[itemprop=cookTime]').text.to_i
151
+ @preptime = sanitize(page.css('ul.c-recipe-summary > li.c-recipe-summary__rating[title="Temps de préparation"]').text).to_i
152
+ @cooktime = sanitize(page.css('ul.c-recipe-summary > li.c-recipe-summary__rating[title="Temps de cuisson"]').text).to_i
152
153
 
153
154
  @steps = []
154
155
  css_step = "div[itemprop=recipeInstructions] p"
@@ -166,9 +167,9 @@ module RecipeScraper
166
167
  @image = page.css(css_image).attr('src').to_s
167
168
  rescue NoMethodError => e
168
169
  end
169
-
170
+
170
171
  else
171
- raise ArgumentError, "Instantiation cancelled (ulr not from #{G750_HOST})."
172
+ raise ArgumentError, "Instantiation cancelled (ulr not from #{G750_HOST})."
172
173
  end
173
174
  end
174
175
 
@@ -185,27 +186,26 @@ module RecipeScraper
185
186
  @preptime = page.css('#ctl00_ContentPlaceHolder_LblRecetteTempsPrepa').text.to_i
186
187
  @cooktime = page.css('#ctl00_ContentPlaceHolder_LblRecetteTempsCuisson').text.to_i
187
188
 
188
-
189
189
  @steps = []
190
- page.css("#preparation span p.fs17").each { |step_node|
190
+ page.css("#preparation p").each { |step_node|
191
191
  @steps << sanitize(step_node.text)
192
192
  }
193
193
 
194
194
  @ingredients = []
195
- page.css("#ingredients li").each { |ing_node|
195
+ page.css("section.recipe_ingredients li").each { |ing_node|
196
196
  @ingredients << sanitize(ing_node.text)
197
197
  }
198
198
 
199
199
  begin
200
- @image = page.css('#shareimg').attr('src').to_s
200
+ @image = page.css('#ctl00_ContentPlaceHolder_recipeImgLarge').attr('src').to_s
201
201
  rescue NoMethodError => e
202
202
  end
203
-
203
+
204
204
  else
205
- raise ArgumentError, "Instantiation cancelled (ulr not from #{G750_HOST})."
205
+ raise ArgumentError, "Instantiation cancelled (ulr not from #{G750_HOST})."
206
206
  end
207
207
  end
208
-
208
+
209
209
  end
210
210
 
211
211
  end
@@ -1,3 +1,3 @@
1
1
  module RecipeScraper
2
- VERSION = "2.2.1"
2
+ VERSION = "2.2.2"
3
3
  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.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - madeindjs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-07 00:00:00.000000000 Z
11
+ date: 2017-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.5.1
110
+ rubygems_version: 2.6.11
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: A web scrawler to get a Marmiton's, cuisineaz or 750g recipe