spidy 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/spidy/connector/html.rb +9 -4
- data/lib/spidy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6e8adabd5eef99735eb1e4ab44609e2f25a859b5604bb2512a8692b72dd0c9e
|
4
|
+
data.tar.gz: ab748cec4971ae35044860ddc26465aaac67d56f47677919f47a3562bd29080a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 747950afd87f68df3572aeb8859af14087a75bd1786c5183719ce94f7964c397e9b81a58c563f1a54883322620b7aa64d580144ec25e0fe4f85c20463ed21d68
|
7
|
+
data.tar.gz: c2d972491eedbdb5308ceda060c71c95a409f9b4968a5897baf93a137d8f17411ad1afa9bfed7e93b0b5a177a706a358da56dc28a86e7dfe3f65152174b22ce8
|
data/Gemfile.lock
CHANGED
data/lib/spidy/connector/html.rb
CHANGED
@@ -17,21 +17,26 @@ module Spidy::Connector::Html
|
|
17
17
|
@agent.user_agent = USER_AGENT
|
18
18
|
|
19
19
|
class << self
|
20
|
-
|
20
|
+
attr_reader :agent
|
21
|
+
|
22
|
+
def call(url, encoding: nil, retry_count: 3, &yielder)
|
21
23
|
if encoding
|
22
24
|
@agent.default_encoding = encoding
|
23
25
|
@agent.force_default_encoding = true
|
24
26
|
end
|
25
|
-
get(url, yielder)
|
27
|
+
get(url, retry_count, yielder)
|
26
28
|
end
|
27
29
|
|
28
|
-
|
30
|
+
private
|
31
|
+
|
32
|
+
def get(url, retry_count, yielder)
|
29
33
|
@agent.get(url, &yielder)
|
30
34
|
rescue Mechanize::ResponseCodeError => e
|
35
|
+
retry_count -= 1
|
31
36
|
case e.response_code
|
32
37
|
when '429'
|
33
38
|
sleep 2
|
34
|
-
|
39
|
+
retry if retry_count
|
35
40
|
else
|
36
41
|
raise e
|
37
42
|
end
|
data/lib/spidy/version.rb
CHANGED