phantom_client 1.2.3 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/phantom_client +1 -1
- data/lib/phantom_client/phantom_client.rb +22 -8
- metadata +4 -4
data/bin/phantom_client
CHANGED
@@ -26,4 +26,4 @@ if url == nil
|
|
26
26
|
end
|
27
27
|
|
28
28
|
client = PhantomJSProxy::PhantomJSClient.new(proxy_list, hmac_key, nil, PhantomJSProxy::PhantomJSClientConnection.new)
|
29
|
-
puts client.get_body(url, {
|
29
|
+
puts client.get_body(url, {"imageOnly" => false, "withIframes" => true})
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'uri'
|
3
3
|
require 'hmac-md5'
|
4
|
+
require "base64"
|
4
5
|
|
5
6
|
module PhantomJSProxy
|
6
7
|
class DummyResponse
|
@@ -47,13 +48,8 @@ module PhantomJSProxy
|
|
47
48
|
get(addr, options).body
|
48
49
|
end
|
49
50
|
|
50
|
-
def get(
|
51
|
-
url =
|
52
|
-
req = Net::HTTP::Get.new(url.path)
|
53
|
-
req['User-Agent'] = "PhantomJSClient"
|
54
|
-
if /\?/.match(addr)
|
55
|
-
req.body = addr.split('?')[1]
|
56
|
-
end
|
51
|
+
def get(addr_in, options=nil)
|
52
|
+
addr,url, req = generate_request(addr_in)
|
57
53
|
|
58
54
|
if options && options['imageOnly']
|
59
55
|
req['Get-Page-As-Image'] = options['imageOnly']
|
@@ -86,7 +82,25 @@ module PhantomJSProxy
|
|
86
82
|
req['Hmac-Time'] = t
|
87
83
|
logger.info "Encode: #{addr} to #{req['Hmac-Key']}"
|
88
84
|
end
|
89
|
-
|
85
|
+
|
86
|
+
def generate_request(addr)
|
87
|
+
begin
|
88
|
+
url = URI.parse(addr)
|
89
|
+
req = Net::HTTP::Get.new(url.path)
|
90
|
+
req['User-Agent'] = "PhantomJSClient"
|
91
|
+
req.body = url.query
|
92
|
+
return addr, url, req
|
93
|
+
rescue URI::InvalidURIError
|
94
|
+
#this now means we got a bad url
|
95
|
+
addr_out = "http://phantomProxy.get/"
|
96
|
+
url = URI.parse(addr_out)
|
97
|
+
req = Net::HTTP::Get.new(url.path)
|
98
|
+
req['User-Agent'] = "PhantomJSClient"
|
99
|
+
req.body = "address="+Base64.encode64(addr)
|
100
|
+
return addr_out, url, req
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
90
104
|
def do_get(url, req, count)
|
91
105
|
element = get_proxy()
|
92
106
|
if element[:addr] && element[:port]
|
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
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 5
|
10
|
+
version: 1.2.5
|
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:
|
18
|
+
date: 2013-04-23 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|