phantom_client 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,10 @@ require 'net/http'
|
|
2
2
|
require 'uri'
|
3
3
|
|
4
4
|
module PhantomJSProxy
|
5
|
+
class DummyResponse
|
6
|
+
attr_accessor :body
|
7
|
+
attr_accessor :code
|
8
|
+
end
|
5
9
|
class PhantomJSClient
|
6
10
|
|
7
11
|
attr_accessor :proxy_addr
|
@@ -14,6 +18,10 @@ module PhantomJSProxy
|
|
14
18
|
@connection = con
|
15
19
|
end
|
16
20
|
|
21
|
+
def get_body(addr, options=nil)
|
22
|
+
get(addr, options).body
|
23
|
+
end
|
24
|
+
|
17
25
|
def get(addr, options=nil)
|
18
26
|
url = URI.parse(addr)
|
19
27
|
req = Net::HTTP::Get.new(url.path)
|
@@ -28,7 +36,7 @@ module PhantomJSProxy
|
|
28
36
|
end
|
29
37
|
|
30
38
|
if options && options['withIframes']
|
31
|
-
req['
|
39
|
+
req['Get-Page-With-IFrames'] = options['withIframes']
|
32
40
|
puts "Do fetch iframes"
|
33
41
|
end
|
34
42
|
#::Proxy(@proxy_addr, @proxy_port)
|
@@ -54,7 +62,10 @@ module PhantomJSProxy
|
|
54
62
|
@connection.do_request(element, url, req)
|
55
63
|
rescue
|
56
64
|
if count == 0
|
57
|
-
|
65
|
+
resp = DummyResponse.new()
|
66
|
+
resp.code = 500
|
67
|
+
resp.body ="Could not connect to proxy"
|
68
|
+
return resp
|
58
69
|
end
|
59
70
|
do_get(url, req, count-1)
|
60
71
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phantom_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Sudmann
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-04-19 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|