recipe_crawler 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -5
- data/lib/recipe_crawler/version.rb +1 -1
- data/lib/recipe_crawler.rb +5 -52
- data/recipe_crawler.gemspec +6 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89724169688d20b40e62c446b5aabada46cff9d5
|
4
|
+
data.tar.gz: 0f04b9336ccbbac34b7a03e984818b3ac83d1ba3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 637f23b5a4bb49f48f4269009fcaec4155fae268c9cd4dbe65494f6048b745d6e6e99eef075ac232b9688078de169bffb5df17359a0b736682af64ccd4999c61
|
7
|
+
data.tar.gz: 5a2e5f744823dc0438be65741985b0b2d2c2466694590c30886f71e4c039eca5d1aa4698c5d38ffbdab7fa260fb0deb95fe22cfcc1efd944c313b37d8ab01928
|
data/README.md
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
# RecipeCrawler
|
2
2
|
|
3
|
-
A web scrawler to get
|
4
|
-
|
5
|
-
* [marmiton.org](http://www.marmiton.org/)
|
6
|
-
* [750g.com](http://www.750g.com)
|
7
|
-
* [cuisineaz.com](http://www.cuisineaz.com)
|
3
|
+
A web scrawler to get a [Marmiton](http://www.marmiton.org/) or [750g](http://www.750g.com)*(two famous french cooking recipe websites)*!
|
8
4
|
|
9
5
|
You'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/recipe_crawler`. To experiment with that code, run `bin/console` for an interactive prompt.
|
10
6
|
|
data/lib/recipe_crawler.rb
CHANGED
@@ -14,8 +14,7 @@ module RecipeCrawler
|
|
14
14
|
attr_reader :title, :preptime, :cooktime , :ingredients, :steps, :image
|
15
15
|
|
16
16
|
MARMITON_HOST = {desktop: 'http://www.marmiton.org/', mobile: 'http://m.marmiton.org/'}
|
17
|
-
G750_HOST =
|
18
|
-
CUISINEAZ_HOST = {desktop: 'http://www.cuisineaz.com/'}
|
17
|
+
G750_HOST = 'http://www.750g.com'
|
19
18
|
|
20
19
|
|
21
20
|
|
@@ -23,15 +22,13 @@ module RecipeCrawler
|
|
23
22
|
#
|
24
23
|
# @param url [String] representing an url from Marmiton or 750g website
|
25
24
|
def initialize url
|
25
|
+
|
26
|
+
warn "[DEPRECATION] `RecipeCrawler` is deprecated. Please download & use `RecipeSraper` instead."
|
27
|
+
|
26
28
|
if marmiton_host? url
|
27
29
|
fetch_from_marmiton url
|
28
|
-
|
29
30
|
elsif g750_host? url
|
30
31
|
fetch_from_g750 url
|
31
|
-
|
32
|
-
elsif cuisineaz_host? url
|
33
|
-
fetch_from_cuisineaz url
|
34
|
-
|
35
32
|
else
|
36
33
|
raise ArgumentError, "Instantiation cancelled (Host not supported)."
|
37
34
|
end
|
@@ -73,7 +70,6 @@ module RecipeCrawler
|
|
73
70
|
return text
|
74
71
|
end
|
75
72
|
|
76
|
-
|
77
73
|
# test if url is from a valid marmiton.org host
|
78
74
|
#
|
79
75
|
# @param url [String] representing an url
|
@@ -88,16 +84,7 @@ module RecipeCrawler
|
|
88
84
|
# @param url [String] representing an url
|
89
85
|
# @return [Boolean] as true if coresponding to a valid url
|
90
86
|
def g750_host? url
|
91
|
-
return url.include? G750_HOST
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
# test if url is from a valid cuisineaz.com host
|
96
|
-
#
|
97
|
-
# @param url [String] representing an url
|
98
|
-
# @return [Boolean] as true if coresponding to a valid url
|
99
|
-
def cuisineaz_host? url
|
100
|
-
return url.include? CUISINEAZ_HOST[:desktop]
|
87
|
+
return url.include? G750_HOST
|
101
88
|
end
|
102
89
|
|
103
90
|
|
@@ -170,40 +157,6 @@ module RecipeCrawler
|
|
170
157
|
raise ArgumentError, "Instantiation cancelled (ulr not from #{G750_HOST})."
|
171
158
|
end
|
172
159
|
end
|
173
|
-
|
174
|
-
|
175
|
-
# fill object properties from a 750g url
|
176
|
-
#
|
177
|
-
# @param url [String] representing an url
|
178
|
-
def fetch_from_cuisineaz url
|
179
|
-
if cuisineaz_host? url
|
180
|
-
page = Nokogiri::HTML(open(url).read)
|
181
|
-
@title = page.css('#ficheRecette h1.fs36').text
|
182
|
-
|
183
|
-
# get times
|
184
|
-
@preptime = page.css('#ctl00_ContentPlaceHolder_LblRecetteTempsPrepa').text.to_i
|
185
|
-
@cooktime = page.css('#ctl00_ContentPlaceHolder_LblRecetteTempsCuisson').text.to_i
|
186
|
-
|
187
|
-
|
188
|
-
@steps = []
|
189
|
-
page.css("#preparation span p.fs17").each { |step_node|
|
190
|
-
@steps << sanitize(step_node.text)
|
191
|
-
}
|
192
|
-
|
193
|
-
@ingredients = []
|
194
|
-
page.css("#ingredients ul li span").each { |ing_node|
|
195
|
-
@ingredients << sanitize(ing_node.text)
|
196
|
-
}
|
197
|
-
|
198
|
-
begin
|
199
|
-
@image = page.css('#shareimg').attr('src').to_s
|
200
|
-
rescue NoMethodError => e
|
201
|
-
end
|
202
|
-
|
203
|
-
else
|
204
|
-
raise ArgumentError, "Instantiation cancelled (ulr not from #{G750_HOST})."
|
205
|
-
end
|
206
|
-
end
|
207
160
|
|
208
161
|
end
|
209
162
|
|
data/recipe_crawler.gemspec
CHANGED
@@ -23,4 +23,10 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
24
|
spec.add_development_dependency "rspec", "~> 3.0"
|
25
25
|
spec.add_development_dependency "nokogiri"
|
26
|
+
|
27
|
+
spec.post_install_message = <<-MESSAGE
|
28
|
+
! The 'recipe_crawler' gem has been deprecated and has been replaced by 'recipe_scraper'.
|
29
|
+
! See: https://rubygems.org/gems/recipe_scraper
|
30
|
+
! And: https://github.com/madeindjs/recipe_scraper
|
31
|
+
MESSAGE
|
26
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recipe_crawler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- madeindjs
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -91,7 +91,10 @@ homepage: https://github.com/madeindjs/recipe_crawler
|
|
91
91
|
licenses:
|
92
92
|
- MIT
|
93
93
|
metadata: {}
|
94
|
-
post_install_message:
|
94
|
+
post_install_message: |
|
95
|
+
! The 'recipe_crawler' gem has been deprecated and has been replaced by 'recipe_scraper'.
|
96
|
+
! See: https://rubygems.org/gems/recipe_scraper
|
97
|
+
! And: https://github.com/madeindjs/recipe_scraper
|
95
98
|
rdoc_options: []
|
96
99
|
require_paths:
|
97
100
|
- lib
|
@@ -107,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
110
|
version: '0'
|
108
111
|
requirements: []
|
109
112
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.4.8
|
111
114
|
signing_key:
|
112
115
|
specification_version: 4
|
113
116
|
summary: A web scrawler to get a Marmiton's or 750g recipe
|