e360-tuiguang 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/e360/tuiguang.rb +4 -2
- data/lib/e360/tuiguang/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bbea6197ed4d3bf94a8c30c9c20b9662debc884
|
4
|
+
data.tar.gz: 7ec94d849b7f014cab2f4864a82aae2e6dd930ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5f78ab221b37c094dc33f4ab29f19009f409f98585761f4a0d5413b97c33161c2ec5dd45e61ec09d1cc4f6d691d8076c3963b282586a6734785735b2f5d3dbd
|
7
|
+
data.tar.gz: 8816ece9bb2e8a75b3f4050fd62483ebcda3ea29aea8c83135e53b93f7cf6795ed0e7c3b2b670c0846cf381676f202bbda0fa80ce408bc8d6920107f49fed124
|
data/lib/e360/tuiguang.rb
CHANGED
@@ -151,6 +151,7 @@ module E360
|
|
151
151
|
request["referer"] = "http://dianjing.e.360.cn/adrank?_=#{Time.now.strftime('%s%L')}"
|
152
152
|
request["upgrade-insecure-requests"] = '1'
|
153
153
|
request["user-agent"] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'
|
154
|
+
retry_times = 0
|
154
155
|
begin
|
155
156
|
puts "Url: #{@req_url}"
|
156
157
|
response = http.request(request)
|
@@ -160,12 +161,13 @@ module E360
|
|
160
161
|
raise LoginExpired
|
161
162
|
end
|
162
163
|
end
|
163
|
-
raise RequestError, "HTTP Response: #{response.code} #{response.message}" unless response.is_a?(Net::HTTPSuccess)
|
164
164
|
unless response.is_a?(Net::HTTPSuccess)
|
165
|
+
retry_times += 1
|
165
166
|
p 'Sleep 3s'
|
166
167
|
sleep 3
|
167
168
|
end
|
168
|
-
end
|
169
|
+
end if !response.is_a?(Net::HTTPSuccess) && retry_times < 10
|
170
|
+
raise RequestError, "HTTP Response: #{response.code} #{response.message}" unless response.is_a?(Net::HTTPSuccess)
|
169
171
|
@resp = response.read_body
|
170
172
|
if response['Content-Encoding'] && response['Content-Encoding'].include?('gzip')
|
171
173
|
@resp = Zlib::GzipReader.new(StringIO.new(@resp)).read
|