micro_spider 0.1.21 → 0.1.22
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/micro_spider.rb +21 -8
- data/lib/spider_core/version.rb +1 -1
- metadata +2 -2
data/lib/micro_spider.rb
CHANGED
@@ -277,14 +277,21 @@ class MicroSpider
|
|
277
277
|
}
|
278
278
|
end
|
279
279
|
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
280
|
+
# @example
|
281
|
+
# spider = MicroSpider.new
|
282
|
+
# kid = spider.spawn
|
283
|
+
#
|
284
|
+
# or
|
285
|
+
#
|
286
|
+
# kid = spider.spawn do
|
287
|
+
# ...
|
288
|
+
# ...
|
289
|
+
# end
|
290
|
+
def spawn(&block)
|
291
|
+
spider = self.class.new
|
292
|
+
spider.logger = logger
|
293
|
+
spider.timeout = timeout
|
294
|
+
spider.learn(&block) if block_given?
|
288
295
|
spider
|
289
296
|
end
|
290
297
|
|
@@ -300,6 +307,12 @@ class MicroSpider
|
|
300
307
|
class << self; self; end
|
301
308
|
end
|
302
309
|
|
310
|
+
# The default page is Capybara.current_session.
|
311
|
+
# Share one page may cause difficult issue, so here i separate it.
|
312
|
+
def page
|
313
|
+
@page ||= Capybara::Session.new(Capybara.mode, Capybara.app)
|
314
|
+
end
|
315
|
+
|
303
316
|
protected
|
304
317
|
def sleep_or_not
|
305
318
|
if delay && delay > 0
|
data/lib/spider_core/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: micro_spider
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.22
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-03-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capybara
|