grabzit 3.2.9.3 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/grabzit/client.rb +25 -11
- data/lib/grabzit/proxy.rb +38 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09d6ec1f09ecdd48022de7301a78464e58d951e1
|
4
|
+
data.tar.gz: 4bc0cece63914f029c41d63edbb356129aea37b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cad38a6aa07db5e8f9f55317e66ac6338b55326b0f1f6e1d87ba51176806bc6188c36d4dd66bac4fdeff5854680ded8d792e47a5f8175dcd679894e6289d8f88
|
7
|
+
data.tar.gz: 9d3587e9c22066f83cccfda42c61984a807f1635c1e553988b305fa9e06d5e69beb148ed3b46874563c95a1737aed07b884eac3218405775a0588cf24db732a7
|
data/lib/grabzit/client.rb
CHANGED
@@ -19,6 +19,7 @@ module GrabzIt
|
|
19
19
|
require File.join(File.dirname(__FILE__), 'tableoptions')
|
20
20
|
require File.join(File.dirname(__FILE__), 'pdfoptions')
|
21
21
|
require File.join(File.dirname(__FILE__), 'docxoptions')
|
22
|
+
require File.join(File.dirname(__FILE__), 'proxy')
|
22
23
|
|
23
24
|
# This client provides access to the GrabzIt web services
|
24
25
|
# This API allows you to take screenshot of websites for free and convert them into images, PDF's and tables.
|
@@ -57,6 +58,7 @@ module GrabzIt
|
|
57
58
|
@applicationKey = applicationKey
|
58
59
|
@applicationSecret = applicationSecret
|
59
60
|
@protocol = 'http'
|
61
|
+
@proxy = Proxy.new()
|
60
62
|
end
|
61
63
|
|
62
64
|
# This method specifies the URL of the online video that should be converted into a animated GIF
|
@@ -261,15 +263,6 @@ module GrabzIt
|
|
261
263
|
|
262
264
|
return get_result_value(data, "ID")
|
263
265
|
end
|
264
|
-
|
265
|
-
private
|
266
|
-
def take(sig, callBackURL)
|
267
|
-
if !@request.isPost()
|
268
|
-
return get(@request.url() + "?" + URI.encode_www_form(@request.options()._getParameters(@applicationKey, sig, callBackURL, "url", @request.data())))
|
269
|
-
end
|
270
|
-
|
271
|
-
return post(@request.url(), URI.encode_www_form(@request.options()._getParameters(@applicationKey, sig, callBackURL, "html", CGI.escape(@request.data()))))
|
272
|
-
end
|
273
266
|
|
274
267
|
# Calls the GrabzIt web service to take the screenshot and saves it to the target path provided. if no target path is provided
|
275
268
|
# it returns the screenshot byte data.
|
@@ -561,6 +554,18 @@ module GrabzIt
|
|
561
554
|
@protocol = 'http'
|
562
555
|
end
|
563
556
|
end
|
557
|
+
|
558
|
+
# This method enables a local proxy server to be used for all requests
|
559
|
+
#
|
560
|
+
# @param value [String] the URL, which can include a port if required, of the proxy. Providing a null will remove any previously set proxy
|
561
|
+
def set_local_proxy(value)
|
562
|
+
if value
|
563
|
+
uri = URI.parse(value)
|
564
|
+
@proxy = Proxy.new(uri.host, uri.port, uri.user, uri.password)
|
565
|
+
else
|
566
|
+
@proxy = Proxy.new()
|
567
|
+
end
|
568
|
+
end
|
564
569
|
|
565
570
|
# This method creates a cryptographically secure encryption key to pass to the encryption key parameter.
|
566
571
|
#
|
@@ -599,6 +604,15 @@ module GrabzIt
|
|
599
604
|
decrypted << cipher.final();
|
600
605
|
return decrypted
|
601
606
|
end
|
607
|
+
|
608
|
+
private
|
609
|
+
def take(sig, callBackURL)
|
610
|
+
if !@request.isPost()
|
611
|
+
return get(@request.url() + "?" + URI.encode_www_form(@request.options()._getParameters(@applicationKey, sig, callBackURL, "url", @request.data())))
|
612
|
+
end
|
613
|
+
|
614
|
+
return post(@request.url(), URI.encode_www_form(@request.options()._getParameters(@applicationKey, sig, callBackURL, "html", CGI.escape(@request.data()))))
|
615
|
+
end
|
602
616
|
|
603
617
|
private
|
604
618
|
def find_watermarks(identifier = nil)
|
@@ -631,7 +645,7 @@ module GrabzIt
|
|
631
645
|
private
|
632
646
|
def get(url)
|
633
647
|
uri = URI.parse(url)
|
634
|
-
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.get(uri.request_uri) }
|
648
|
+
response = Net::HTTP.start(uri.host, uri.port, @proxy.host(), @proxy.port(), @proxy.username(), @proxy.password(), :use_ssl => uri.scheme == 'https') { |http| http.get(uri.request_uri) }
|
635
649
|
response_check(response)
|
636
650
|
return response.body
|
637
651
|
end
|
@@ -640,7 +654,7 @@ module GrabzIt
|
|
640
654
|
def post(url, params)
|
641
655
|
headers = {'Content-Type' => 'application/x-www-form-urlencoded'}
|
642
656
|
uri = URI.parse(url)
|
643
|
-
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.post(uri.request_uri, params, headers) }
|
657
|
+
response = Net::HTTP.start(uri.host, uri.port, @proxy.host(), @proxy.port(), @proxy.username(), @proxy.password(), :use_ssl => uri.scheme == 'https') { |http| http.post(uri.request_uri, params, headers) }
|
644
658
|
response_check(response)
|
645
659
|
return response.body
|
646
660
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module GrabzIt
|
2
|
+
require 'cgi'
|
3
|
+
|
4
|
+
# This class represents the local proxy
|
5
|
+
# @version 3.2
|
6
|
+
# @author GrabzIt
|
7
|
+
class Proxy
|
8
|
+
# @!visibility private
|
9
|
+
def initialize(host = nil, port = nil, username = nil, password = nil)
|
10
|
+
@Host = host
|
11
|
+
@Port = port
|
12
|
+
@Username = username
|
13
|
+
@Password = password
|
14
|
+
end
|
15
|
+
# @return [String] returns the host of the proxy
|
16
|
+
def host
|
17
|
+
@Host
|
18
|
+
end
|
19
|
+
# @return [String] returns the port of the proxy
|
20
|
+
def port
|
21
|
+
@Port
|
22
|
+
end
|
23
|
+
# @return [String] returns the username of the proxy
|
24
|
+
def username
|
25
|
+
if @Username == nil
|
26
|
+
return @Username
|
27
|
+
end
|
28
|
+
return CGI.unescape(@Username)
|
29
|
+
end
|
30
|
+
# @return [String] [String] returns the password of the proxy
|
31
|
+
def password
|
32
|
+
if @Password == nil
|
33
|
+
return @Password
|
34
|
+
end
|
35
|
+
return CGI.unescape(@Password)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grabzit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GrabzIt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- lib/grabzit/exception.rb
|
45
45
|
- lib/grabzit/imageoptions.rb
|
46
46
|
- lib/grabzit/pdfoptions.rb
|
47
|
+
- lib/grabzit/proxy.rb
|
47
48
|
- lib/grabzit/request.rb
|
48
49
|
- lib/grabzit/screenshotstatus.rb
|
49
50
|
- lib/grabzit/tableoptions.rb
|