klepto 0.6.7 → 0.6.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/klepto/bot.rb +5 -1
- data/lib/klepto/config.rb +10 -0
- data/lib/klepto/version.rb +1 -1
- metadata +1 -1
data/lib/klepto/bot.rb
CHANGED
@@ -62,7 +62,11 @@ EOS
|
|
62
62
|
|
63
63
|
# This is here to debug, having a weird issue with getting a 200 and sometimes
|
64
64
|
# returning @browser.failure? => true
|
65
|
-
|
65
|
+
sleep_counter = 0
|
66
|
+
while @browser.status.nil? && sleep_counter < @config.sleep_tries
|
67
|
+
sleep_counter +=1
|
68
|
+
sleep @config.sleep
|
69
|
+
end
|
66
70
|
|
67
71
|
# If the page was not a failure or if not aborting, structure that bad boy.
|
68
72
|
if (@browser.failure? && @config.abort_on_failure?)
|
data/lib/klepto/config.rb
CHANGED
@@ -6,6 +6,8 @@ module Klepto
|
|
6
6
|
def initialize
|
7
7
|
@headers = {}
|
8
8
|
@abort_on_failure = true
|
9
|
+
@sleep = 0.5
|
10
|
+
@sleep_tries = 10
|
9
11
|
@abort_on_redirect = false
|
10
12
|
@after_handlers = {
|
11
13
|
:structure => [], #after each call to
|
@@ -24,6 +26,14 @@ module Klepto
|
|
24
26
|
# @handlers[group][handler].each{|handler| handler.call(*args)}
|
25
27
|
# end
|
26
28
|
|
29
|
+
def sleep(_sleep=nil)
|
30
|
+
@sleep = _sleep
|
31
|
+
end
|
32
|
+
|
33
|
+
def sleep_tries(_sleep_tries=nil)
|
34
|
+
@sleep_tries = _sleep_tries
|
35
|
+
end
|
36
|
+
|
27
37
|
def driver(_driver=nil)
|
28
38
|
@default_driver = _driver if _driver
|
29
39
|
@default_driver
|
data/lib/klepto/version.rb
CHANGED