Class: PhantomJSProxy::PhantomJSClient
- Inherits:
-
Object
- Object
- PhantomJSProxy::PhantomJSClient
- Defined in:
- lib/phantom_client/phantom_client.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#hmac ⇒ Object
Returns the value of attribute hmac.
-
#hmac_activated ⇒ Object
Returns the value of attribute hmac_activated.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#proxy_addr ⇒ Object
Returns the value of attribute proxy_addr.
-
#proxy_list ⇒ Object
Returns the value of attribute proxy_list.
-
#proxy_port ⇒ Object
Returns the value of attribute proxy_port.
Instance Method Summary collapse
- #get(addr_in, options = nil) ⇒ Object
- #get_body(addr, options = nil) ⇒ Object
-
#initialize(addr_list = [], key = nil, log = nil, con = PhantomJSClientConnection.new) ⇒ PhantomJSClient
constructor
A new instance of PhantomJSClient.
Constructor Details
#initialize(addr_list = [], key = nil, log = nil, con = PhantomJSClientConnection.new) ⇒ PhantomJSClient
Returns a new instance of PhantomJSClient.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/phantom_client/phantom_client.rb', line 35 def initialize(addr_list=[], key=nil, log=nil, con = PhantomJSClientConnection.new) @proxy_list = addr_list @connection = con @hmac_activated = key ? true : false @hmac = HMAC::MD5.new key @logger = log if @logger == nil @logger = DummyLogger.new end logger.info "Using #{key} as HMAC key" end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
30 31 32 |
# File 'lib/phantom_client/phantom_client.rb', line 30 def connection @connection end |
#hmac ⇒ Object
Returns the value of attribute hmac.
31 32 33 |
# File 'lib/phantom_client/phantom_client.rb', line 31 def hmac @hmac end |
#hmac_activated ⇒ Object
Returns the value of attribute hmac_activated.
32 33 34 |
# File 'lib/phantom_client/phantom_client.rb', line 32 def hmac_activated @hmac_activated end |
#logger ⇒ Object
Returns the value of attribute logger.
33 34 35 |
# File 'lib/phantom_client/phantom_client.rb', line 33 def logger @logger end |
#proxy_addr ⇒ Object
Returns the value of attribute proxy_addr.
27 28 29 |
# File 'lib/phantom_client/phantom_client.rb', line 27 def proxy_addr @proxy_addr end |
#proxy_list ⇒ Object
Returns the value of attribute proxy_list.
29 30 31 |
# File 'lib/phantom_client/phantom_client.rb', line 29 def proxy_list @proxy_list end |
#proxy_port ⇒ Object
Returns the value of attribute proxy_port.
28 29 30 |
# File 'lib/phantom_client/phantom_client.rb', line 28 def proxy_port @proxy_port end |
Instance Method Details
#get(addr_in, options = nil) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/phantom_client/phantom_client.rb', line 51 def get(addr_in, =nil) addr,url, req = generate_request(addr_in) if && ['imageOnly'] req['Get-Page-As-Image'] = ['imageOnly'] logger.info "Do image only" end if && ['withIframes'] req['Get-Page-With-IFrames'] = ['withIframes'] logger.info "Do fetch iframes" end if hmac_activated update_hmac_head addr, req, hmac end #::Proxy(@proxy_addr, @proxy_port) #element = get_proxy() #begin # @connection.do_request(element, url, req) #rescue # return "Could not connect to proxy" #end do_get(url, req, 10) end |
#get_body(addr, options = nil) ⇒ Object
47 48 49 |
# File 'lib/phantom_client/phantom_client.rb', line 47 def get_body(addr, =nil) get(addr, ).body end |