grabzit 3.3.4.1 → 3.5.0
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.
- checksums.yaml +5 -5
- data/lib/grabzit/client.rb +63 -23
- data/lib/grabzit/docxoptions.rb +33 -3
- data/lib/grabzit/exception.rb +4 -0
- data/lib/grabzit/htmloptions.rb +161 -0
- data/lib/grabzit/imageoptions.rb +16 -1
- data/lib/grabzit/pdfoptions.rb +50 -4
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ee2e4b1cfbe4852f4caef8693d3e615449280c6842de2ec0fb25adadf06bcc96
|
4
|
+
data.tar.gz: edc3e07ea3cb78f48a0fd090fa2520829147ac7503ae78870bdb83a179e86def
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ce530ba3115c87a54343cda7c8d35b8e2a51099b0ca9f39e2411a3612b8e08bd6cedd7cfe53e272a71396711ce22d4387f5312565b674f7a4e3f5a905dceef0
|
7
|
+
data.tar.gz: 4d2ab4167a04e2e85dbe69101c5db926e6aff3c45aa2725a6b5127cbc243588000b5619e0ca8d1968511f0a8202e03dd96b9c1df3835d5d097d3df790bdd5221
|
data/lib/grabzit/client.rb
CHANGED
@@ -16,6 +16,7 @@ module GrabzIt
|
|
16
16
|
require File.join(File.dirname(__FILE__), 'exception')
|
17
17
|
require File.join(File.dirname(__FILE__), 'animationoptions')
|
18
18
|
require File.join(File.dirname(__FILE__), 'imageoptions')
|
19
|
+
require File.join(File.dirname(__FILE__), 'htmloptions')
|
19
20
|
require File.join(File.dirname(__FILE__), 'tableoptions')
|
20
21
|
require File.join(File.dirname(__FILE__), 'pdfoptions')
|
21
22
|
require File.join(File.dirname(__FILE__), 'docxoptions')
|
@@ -34,10 +35,8 @@ module GrabzIt
|
|
34
35
|
# @see http://grabz.it/api/ruby/ GrabzIt Ruby API
|
35
36
|
class Client
|
36
37
|
|
37
|
-
|
38
|
-
private_constant :
|
39
|
-
WebServicesBaseURLPost = "://grabz.it/services/"
|
40
|
-
private_constant :WebServicesBaseURLPost
|
38
|
+
WebServicesBaseURL = "://api.grabz.it/services/"
|
39
|
+
private_constant :WebServicesBaseURL
|
41
40
|
TakePicture = "takepicture.ashx"
|
42
41
|
private_constant :TakePicture
|
43
42
|
TakeTable = "taketable.ashx"
|
@@ -46,6 +45,8 @@ module GrabzIt
|
|
46
45
|
private_constant :TakePDF
|
47
46
|
TakeDOCX = "takedocx.ashx"
|
48
47
|
private_constant :TakeDOCX
|
48
|
+
TakeHTML = "takehtml.ashx"
|
49
|
+
private_constant :TakeHTML
|
49
50
|
TrueString = "True"
|
50
51
|
private_constant :TrueString
|
51
52
|
|
@@ -72,7 +73,7 @@ module GrabzIt
|
|
72
73
|
options = AnimationOptions.new()
|
73
74
|
end
|
74
75
|
|
75
|
-
@request = Request.new(@protocol +
|
76
|
+
@request = Request.new(@protocol + WebServicesBaseURL + "takeanimation.ashx", false, options, url)
|
76
77
|
return nil
|
77
78
|
end
|
78
79
|
|
@@ -87,7 +88,7 @@ module GrabzIt
|
|
87
88
|
options = ImageOptions.new()
|
88
89
|
end
|
89
90
|
|
90
|
-
@request = Request.new(@protocol +
|
91
|
+
@request = Request.new(@protocol + WebServicesBaseURL + TakePicture, false, options, url)
|
91
92
|
return nil
|
92
93
|
end
|
93
94
|
|
@@ -102,7 +103,7 @@ module GrabzIt
|
|
102
103
|
options = ImageOptions.new()
|
103
104
|
end
|
104
105
|
|
105
|
-
@request = Request.new(@protocol +
|
106
|
+
@request = Request.new(@protocol + WebServicesBaseURL + TakePicture, true, options, html)
|
106
107
|
return nil
|
107
108
|
end
|
108
109
|
|
@@ -114,6 +115,45 @@ module GrabzIt
|
|
114
115
|
def file_to_image(path, options = nil)
|
115
116
|
html_to_image(read_file(path), options)
|
116
117
|
end
|
118
|
+
|
119
|
+
# This method specifies the URL that should be converted into rendered HTML
|
120
|
+
#
|
121
|
+
# @param url [String] the URL to capture as rendered HTML
|
122
|
+
# @param options [HTMLOptions, nil] a instance of the HTMLOptions class that defines any special options to use when creating the rendered HTML
|
123
|
+
# @return [void]
|
124
|
+
def url_to_rendered_html(url, options = nil)
|
125
|
+
|
126
|
+
if options == nil
|
127
|
+
options = HTMLOptions.new()
|
128
|
+
end
|
129
|
+
|
130
|
+
@request = Request.new(@protocol + WebServicesBaseURL + TakeHTML, false, options, url)
|
131
|
+
return nil
|
132
|
+
end
|
133
|
+
|
134
|
+
# This method specifies the HTML that should be converted into rendered HTML
|
135
|
+
#
|
136
|
+
# @param html [String] the HTML to convert into rendered HTML
|
137
|
+
# @param options [HTMLOptions, nil] a instance of the HTMLOptions class that defines any special options to use when creating the rendered HTML
|
138
|
+
# @return [void]
|
139
|
+
def html_to_rendered_html(html, options = nil)
|
140
|
+
|
141
|
+
if options == nil
|
142
|
+
options = HTMLOptions.new()
|
143
|
+
end
|
144
|
+
|
145
|
+
@request = Request.new(@protocol + WebServicesBaseURL + TakeHTML, true, options, html)
|
146
|
+
return nil
|
147
|
+
end
|
148
|
+
|
149
|
+
# This method specifies a HTML file that should be converted into rendered HTML
|
150
|
+
#
|
151
|
+
# @param path [String] the file path of a HTML file to convert into rendered HTML
|
152
|
+
# @param options [HTMLOptions, nil] a instance of the HTMLOptions class that defines any special options to use when creating rendered HTML
|
153
|
+
# @return [void]
|
154
|
+
def file_to_rendered_html(path, options = nil)
|
155
|
+
html_to_rendered_html(read_file(path), options)
|
156
|
+
end
|
117
157
|
|
118
158
|
# This method specifies the URL that the HTML tables should be extracted from
|
119
159
|
#
|
@@ -126,7 +166,7 @@ module GrabzIt
|
|
126
166
|
options = TableOptions.new()
|
127
167
|
end
|
128
168
|
|
129
|
-
@request = Request.new(@protocol +
|
169
|
+
@request = Request.new(@protocol + WebServicesBaseURL + TakeTable, false, options, url)
|
130
170
|
return nil
|
131
171
|
end
|
132
172
|
|
@@ -141,7 +181,7 @@ module GrabzIt
|
|
141
181
|
options = TableOptions.new()
|
142
182
|
end
|
143
183
|
|
144
|
-
@request = Request.new(@protocol +
|
184
|
+
@request = Request.new(@protocol + WebServicesBaseURL + TakeTable, true, options, html)
|
145
185
|
return nil
|
146
186
|
end
|
147
187
|
|
@@ -165,7 +205,7 @@ module GrabzIt
|
|
165
205
|
options = PDFOptions.new()
|
166
206
|
end
|
167
207
|
|
168
|
-
@request = Request.new(@protocol +
|
208
|
+
@request = Request.new(@protocol + WebServicesBaseURL + TakePDF, false, options, url)
|
169
209
|
return nil
|
170
210
|
end
|
171
211
|
|
@@ -180,7 +220,7 @@ module GrabzIt
|
|
180
220
|
options = PDFOptions.new()
|
181
221
|
end
|
182
222
|
|
183
|
-
@request = Request.new(@protocol +
|
223
|
+
@request = Request.new(@protocol + WebServicesBaseURL + TakePDF, true, options, html)
|
184
224
|
return nil
|
185
225
|
end
|
186
226
|
|
@@ -204,7 +244,7 @@ module GrabzIt
|
|
204
244
|
options = DOCXOptions.new()
|
205
245
|
end
|
206
246
|
|
207
|
-
@request = Request.new(@protocol +
|
247
|
+
@request = Request.new(@protocol + WebServicesBaseURL + TakeDOCX, false, options, url)
|
208
248
|
return nil
|
209
249
|
end
|
210
250
|
|
@@ -219,7 +259,7 @@ module GrabzIt
|
|
219
259
|
options = DOCXOptions.new()
|
220
260
|
end
|
221
261
|
|
222
|
-
@request = Request.new(@protocol +
|
262
|
+
@request = Request.new(@protocol + WebServicesBaseURL + TakeDOCX, true, options, html)
|
223
263
|
return nil
|
224
264
|
end
|
225
265
|
|
@@ -324,7 +364,7 @@ module GrabzIt
|
|
324
364
|
return nil
|
325
365
|
end
|
326
366
|
|
327
|
-
result = get(@protocol +
|
367
|
+
result = get(@protocol + WebServicesBaseURL + "getstatus.ashx?id=" + GrabzIt::Utility.nil_check(id))
|
328
368
|
|
329
369
|
doc = REXML::Document.new(result)
|
330
370
|
|
@@ -346,7 +386,7 @@ module GrabzIt
|
|
346
386
|
return nil
|
347
387
|
end
|
348
388
|
|
349
|
-
return get(@protocol +
|
389
|
+
return get(@protocol + WebServicesBaseURL + "getfile.ashx?id=" + GrabzIt::Utility.nil_check(id))
|
350
390
|
end
|
351
391
|
|
352
392
|
# Get all the cookies that GrabzIt is using for a particular domain. This may include your user set cookies as well
|
@@ -364,7 +404,7 @@ module GrabzIt
|
|
364
404
|
qs.concat("&sig=")
|
365
405
|
qs.concat(sig)
|
366
406
|
|
367
|
-
result = get(@protocol +
|
407
|
+
result = get(@protocol + WebServicesBaseURL + "getcookies.ashx?" + qs)
|
368
408
|
|
369
409
|
doc = REXML::Document.new(result)
|
370
410
|
|
@@ -419,7 +459,7 @@ module GrabzIt
|
|
419
459
|
qs.concat("&sig=")
|
420
460
|
qs.concat(sig)
|
421
461
|
|
422
|
-
return (get_result_value(get(@protocol +
|
462
|
+
return (get_result_value(get(@protocol + WebServicesBaseURL + "setcookie.ashx?" + qs), "Result") == TrueString)
|
423
463
|
end
|
424
464
|
|
425
465
|
# Delete a custom cookie or block a global cookie from being used
|
@@ -441,7 +481,7 @@ module GrabzIt
|
|
441
481
|
qs.concat("&delete=1&sig=")
|
442
482
|
qs.concat(sig)
|
443
483
|
|
444
|
-
return (get_result_value(get(@protocol +
|
484
|
+
return (get_result_value(get(@protocol + WebServicesBaseURL + "setcookie.ashx?" + qs), "Result") == TrueString)
|
445
485
|
end
|
446
486
|
|
447
487
|
# Get your uploaded custom watermark
|
@@ -481,7 +521,7 @@ module GrabzIt
|
|
481
521
|
|
482
522
|
boundary = '--------------------------'+Time.now.to_f.to_s
|
483
523
|
|
484
|
-
url = @protocol + "://grabz.it/services/addwatermark.ashx"
|
524
|
+
url = @protocol + "://api.grabz.it/services/addwatermark.ashx"
|
485
525
|
uri = URI.parse(url)
|
486
526
|
|
487
527
|
file = File.open(path, "rb")
|
@@ -541,7 +581,7 @@ module GrabzIt
|
|
541
581
|
qs.concat("&sig=")
|
542
582
|
qs.concat(sig)
|
543
583
|
|
544
|
-
return (get_result_value(get(@protocol +
|
584
|
+
return (get_result_value(get(@protocol + WebServicesBaseURL + "deletewatermark.ashx?" + qs), "Result") == TrueString)
|
545
585
|
end
|
546
586
|
|
547
587
|
# This method sets if requests to GrabzIt's API should use SSL or not
|
@@ -625,7 +665,7 @@ module GrabzIt
|
|
625
665
|
qs.concat("&sig=")
|
626
666
|
qs.concat(sig)
|
627
667
|
|
628
|
-
result = get(@protocol +
|
668
|
+
result = get(@protocol + WebServicesBaseURL + "getwatermarks.ashx?" + qs)
|
629
669
|
|
630
670
|
doc = REXML::Document.new(result)
|
631
671
|
|
@@ -665,7 +705,7 @@ module GrabzIt
|
|
665
705
|
if statusCode == 403
|
666
706
|
raise GrabzItException.new(response.body, GrabzItException::NETWORK_DDOS_ATTACK)
|
667
707
|
elsif statusCode >= 400
|
668
|
-
raise GrabzItException.new("A network error
|
708
|
+
raise GrabzItException.new("A network error occurred when connecting to GrabzIt.", GrabzItException::NETWORK_GENERAL_ERROR)
|
669
709
|
end
|
670
710
|
end
|
671
711
|
|
@@ -685,7 +725,7 @@ module GrabzIt
|
|
685
725
|
|
686
726
|
private
|
687
727
|
def encode(text)
|
688
|
-
return Digest::MD5.hexdigest(text.encode('ascii', {:invalid => :replace, :undef => :replace, :replace => '?'}))
|
728
|
+
return Digest::MD5.hexdigest(text.encode('ascii', **{:invalid => :replace, :undef => :replace, :replace => '?'}))
|
689
729
|
end
|
690
730
|
|
691
731
|
private
|
data/lib/grabzit/docxoptions.rb
CHANGED
@@ -30,7 +30,9 @@ module GrabzIt
|
|
30
30
|
@targetElement = nil
|
31
31
|
@mergeId = nil
|
32
32
|
@noCookieNotifications = false
|
33
|
-
@address = nil
|
33
|
+
@address = nil
|
34
|
+
@password = nil
|
35
|
+
@clickElement = nil
|
34
36
|
end
|
35
37
|
|
36
38
|
# @return [Boolean] true if the background images of the web page should be included in the DOCX
|
@@ -295,6 +297,19 @@ module GrabzIt
|
|
295
297
|
@waitForElement = value
|
296
298
|
end
|
297
299
|
|
300
|
+
# @return [String] get the CSS selector of the HTML element in the web page that must clicked before the capture is performed
|
301
|
+
def clickElement
|
302
|
+
@clickElement
|
303
|
+
end
|
304
|
+
|
305
|
+
# Set the CSS selector of the HTML element in the web page that must clicked before the capture is performed
|
306
|
+
#
|
307
|
+
# @param value [String] the element to click
|
308
|
+
# @return [void]
|
309
|
+
def clickElement=(value)
|
310
|
+
@clickElement = value
|
311
|
+
end
|
312
|
+
|
298
313
|
# @return [String] get the ID of a capture that should be merged at the beginning of the new DOCX document
|
299
314
|
def mergeId
|
300
315
|
@mergeId
|
@@ -346,7 +361,20 @@ module GrabzIt
|
|
346
361
|
# @return [void]
|
347
362
|
def address=(value)
|
348
363
|
@address = value
|
349
|
-
end
|
364
|
+
end
|
365
|
+
|
366
|
+
# @return [String] get the password that protects the DOCX document
|
367
|
+
def password
|
368
|
+
@password
|
369
|
+
end
|
370
|
+
|
371
|
+
# Set the password that protects the DOCX document
|
372
|
+
#
|
373
|
+
# @param value [String] the password
|
374
|
+
# @return [void]
|
375
|
+
def password=(value)
|
376
|
+
@password = value
|
377
|
+
end
|
350
378
|
|
351
379
|
# Define a HTTP Post parameter and optionally value, this method can be called multiple times to add multiple parameters. Using this method will force
|
352
380
|
# GrabzIt to perform a HTTP post.
|
@@ -373,7 +401,7 @@ module GrabzIt
|
|
373
401
|
items.push(GrabzIt::Utility.nil_check(url))
|
374
402
|
end
|
375
403
|
|
376
|
-
items.push(GrabzIt::Utility.nil_check(callBackURL),GrabzIt::Utility.nil_check(@customId),GrabzIt::Utility.b_to_str(@includeBackground),@pagesize ,@orientation,GrabzIt::Utility.b_to_str(@includeImages),GrabzIt::Utility.b_to_str(@includeLinks),GrabzIt::Utility.nil_check(@title),GrabzIt::Utility.nil_int_check(@marginTop),GrabzIt::Utility.nil_int_check(@marginLeft),GrabzIt::Utility.nil_int_check(@marginBottom),GrabzIt::Utility.nil_int_check(@marginRight),GrabzIt::Utility.nil_int_check(@delay),GrabzIt::Utility.nil_int_check(@requestAs),GrabzIt::Utility.nil_check(@country),GrabzIt::Utility.nil_int_check(@quality),GrabzIt::Utility.nil_check(@hideElement),GrabzIt::Utility.nil_check(@exportURL),GrabzIt::Utility.nil_check(@waitForElement),GrabzIt::Utility.nil_check(@encryptionKey),GrabzIt::Utility.b_to_str(@noAds),GrabzIt::Utility.nil_check(@post),GrabzIt::Utility.nil_check(@targetElement),GrabzIt::Utility.nil_check(@templateId),GrabzIt::Utility.nil_check(@templateVariables),GrabzIt::Utility.nil_int_check(@height),GrabzIt::Utility.nil_int_check(@width),GrabzIt::Utility.nil_int_check(@browserWidth),GrabzIt::Utility.nil_check(@proxy),GrabzIt::Utility.nil_check(@mergeId),GrabzIt::Utility.nil_check(@address),GrabzIt::Utility.b_to_str(@noCookieNotifications))
|
404
|
+
items.push(GrabzIt::Utility.nil_check(callBackURL),GrabzIt::Utility.nil_check(@customId),GrabzIt::Utility.b_to_str(@includeBackground),@pagesize ,@orientation,GrabzIt::Utility.b_to_str(@includeImages),GrabzIt::Utility.b_to_str(@includeLinks),GrabzIt::Utility.nil_check(@title),GrabzIt::Utility.nil_int_check(@marginTop),GrabzIt::Utility.nil_int_check(@marginLeft),GrabzIt::Utility.nil_int_check(@marginBottom),GrabzIt::Utility.nil_int_check(@marginRight),GrabzIt::Utility.nil_int_check(@delay),GrabzIt::Utility.nil_int_check(@requestAs),GrabzIt::Utility.nil_check(@country),GrabzIt::Utility.nil_int_check(@quality),GrabzIt::Utility.nil_check(@hideElement),GrabzIt::Utility.nil_check(@exportURL),GrabzIt::Utility.nil_check(@waitForElement),GrabzIt::Utility.nil_check(@encryptionKey),GrabzIt::Utility.b_to_str(@noAds),GrabzIt::Utility.nil_check(@post),GrabzIt::Utility.nil_check(@targetElement),GrabzIt::Utility.nil_check(@templateId),GrabzIt::Utility.nil_check(@templateVariables),GrabzIt::Utility.nil_int_check(@height),GrabzIt::Utility.nil_int_check(@width),GrabzIt::Utility.nil_int_check(@browserWidth),GrabzIt::Utility.nil_check(@proxy),GrabzIt::Utility.nil_check(@mergeId),GrabzIt::Utility.nil_check(@address),GrabzIt::Utility.b_to_str(@noCookieNotifications),GrabzIt::Utility.nil_check(@password),GrabzIt::Utility.nil_check(@clickElement))
|
377
405
|
return items.join("|")
|
378
406
|
end
|
379
407
|
|
@@ -406,6 +434,8 @@ module GrabzIt
|
|
406
434
|
params['mergeid'] = GrabzIt::Utility.nil_check(@mergeId)
|
407
435
|
params['address'] = GrabzIt::Utility.nil_check(@address)
|
408
436
|
params['nonotify'] = GrabzIt::Utility.b_to_str(@noCookieNotifications)
|
437
|
+
params['password'] = GrabzIt::Utility.nil_check(@password)
|
438
|
+
params['click'] = GrabzIt::Utility.nil_check(@clickElement)
|
409
439
|
|
410
440
|
return params;
|
411
441
|
end
|
data/lib/grabzit/exception.rb
CHANGED
@@ -72,6 +72,10 @@ module GrabzIt
|
|
72
72
|
PARAMETER_INVALID_PROXY = 173
|
73
73
|
PARAMETER_INVALID_NO_NOTIFY = 174
|
74
74
|
PARAMETER_INVALID_HD = 176
|
75
|
+
PARAMETER_INVALID_MEDIA_TYPE = 177
|
76
|
+
PARAMETER_INVALID_PASSWORD = 178
|
77
|
+
PARAMETER_INVALID_MERGE = 179
|
78
|
+
PARAMETER_INVALID_CLICK_VALUE = 180
|
75
79
|
NETWORK_SERVER_OFFLINE = 200
|
76
80
|
NETWORK_GENERAL_ERROR = 201
|
77
81
|
NETWORK_DDOS_ATTACK = 202
|
@@ -0,0 +1,161 @@
|
|
1
|
+
module GrabzIt
|
2
|
+
require File.join(File.dirname(__FILE__), 'baseoptions')
|
3
|
+
|
4
|
+
# Represents all of the options available when creating rendered HTML
|
5
|
+
# @version 3.0
|
6
|
+
# @author GrabzIt
|
7
|
+
class HTMLOptions < BaseOptions
|
8
|
+
def initialize()
|
9
|
+
super()
|
10
|
+
@browserWidth = nil
|
11
|
+
@browserHeight = nil
|
12
|
+
@waitForElement = nil
|
13
|
+
@requestAs = 0
|
14
|
+
@noAds = false
|
15
|
+
@noCookieNotifications = false
|
16
|
+
@address = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Integer] the width of the browser in pixels
|
20
|
+
def browserWidth
|
21
|
+
@browserWidth
|
22
|
+
end
|
23
|
+
|
24
|
+
# Set the width of the browser in pixels
|
25
|
+
#
|
26
|
+
# @param value [Integer] the browser width
|
27
|
+
# @return [void]
|
28
|
+
def browserWidth=(value)
|
29
|
+
@browserWidth = value
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [Integer] the height of the browser in pixels
|
33
|
+
def browserHeight
|
34
|
+
@browserHeight
|
35
|
+
end
|
36
|
+
|
37
|
+
# Set the height of the browser in pixels. Use -1 to screenshot the whole web page
|
38
|
+
#
|
39
|
+
# @param value [Integer] the browser height
|
40
|
+
# @return [void]
|
41
|
+
def browserHeight=(value)
|
42
|
+
@browserHeight = value
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [Integer] get the number of milliseconds to wait before creating the capture
|
46
|
+
def delay
|
47
|
+
@delay
|
48
|
+
end
|
49
|
+
|
50
|
+
# Set the number of milliseconds to wait before creating the capture
|
51
|
+
#
|
52
|
+
# @param value [Integer] the delay
|
53
|
+
# @return [void]
|
54
|
+
def delay=(value)
|
55
|
+
@delay = value
|
56
|
+
end
|
57
|
+
|
58
|
+
# @return [String] get the CSS selector of the HTML element in the web page that must be visible before the capture is performed
|
59
|
+
def waitForElement
|
60
|
+
@waitForElement
|
61
|
+
end
|
62
|
+
|
63
|
+
# Set the CSS selector of the HTML element in the web page that must be visible before the capture is performed
|
64
|
+
#
|
65
|
+
# @param value [String] the element to wait for
|
66
|
+
# @return [void]
|
67
|
+
def waitForElement=(value)
|
68
|
+
@waitForElement = value
|
69
|
+
end
|
70
|
+
|
71
|
+
# @return [Integer] get which user agent type should be used
|
72
|
+
def requestAs
|
73
|
+
@requestAs
|
74
|
+
end
|
75
|
+
|
76
|
+
# Set which user agent type should be used: Standard Browser = 0, Mobile Browser = 1, Search Engine = 2 and Fallback Browser = 3
|
77
|
+
#
|
78
|
+
# @param value [Integer] the browser type
|
79
|
+
# @return [void]
|
80
|
+
def requestAs=(value)
|
81
|
+
@requestAs = value
|
82
|
+
end
|
83
|
+
|
84
|
+
# @return [Boolean] get if adverts should be automatically hidden
|
85
|
+
def noAds
|
86
|
+
@noAds
|
87
|
+
end
|
88
|
+
|
89
|
+
# Set to true if adverts should be automatically hidden
|
90
|
+
#
|
91
|
+
# @param value [Boolean] hide adverts
|
92
|
+
# @return [void]
|
93
|
+
def noAds=(value)
|
94
|
+
@noAds = value
|
95
|
+
end
|
96
|
+
|
97
|
+
# @return [Boolean] get if cookie notifications should be automatically hidden
|
98
|
+
def noCookieNotifications
|
99
|
+
@noCookieNotifications
|
100
|
+
end
|
101
|
+
|
102
|
+
# Set to true if cookie notifications should be automatically hidden
|
103
|
+
#
|
104
|
+
# @param value [Boolean] hide cookie notifications
|
105
|
+
# @return [void]
|
106
|
+
def noCookieNotifications=(value)
|
107
|
+
@noCookieNotifications = value
|
108
|
+
end
|
109
|
+
|
110
|
+
# @return [String] get the URL to execute the HTML code in
|
111
|
+
def address
|
112
|
+
@address
|
113
|
+
end
|
114
|
+
|
115
|
+
# Set the URL to execute the HTML code in
|
116
|
+
#
|
117
|
+
# @param value [String] the address
|
118
|
+
# @return [void]
|
119
|
+
def address=(value)
|
120
|
+
@address = value
|
121
|
+
end
|
122
|
+
|
123
|
+
# Define a HTTP Post parameter and optionally value, this method can be called multiple times to add multiple parameters. Using this method will force
|
124
|
+
# GrabzIt to perform a HTTP post.
|
125
|
+
#
|
126
|
+
# @param name [String] the name of the HTTP Post parameter
|
127
|
+
# @param value [String] the value of the HTTP Post parameter
|
128
|
+
def add_post_parameter(name, value)
|
129
|
+
@post = appendParameter(@post, name, value)
|
130
|
+
end
|
131
|
+
|
132
|
+
# @!visibility private
|
133
|
+
def _getSignatureString(applicationSecret, callBackURL, url = nil)
|
134
|
+
items = [applicationSecret]
|
135
|
+
|
136
|
+
if(url != nil)
|
137
|
+
items.push(GrabzIt::Utility.nil_check(url))
|
138
|
+
end
|
139
|
+
|
140
|
+
items.push(GrabzIt::Utility.nil_check(callBackURL),GrabzIt::Utility.nil_int_check(@browserHeight),GrabzIt::Utility.nil_int_check(@browserWidth),GrabzIt::Utility.nil_check(@customId),GrabzIt::Utility.nil_int_check(@delay),GrabzIt::Utility.nil_int_check(@requestAs),GrabzIt::Utility.nil_check(@country),GrabzIt::Utility.nil_check(@exportURL),GrabzIt::Utility.nil_check(@waitForElement),GrabzIt::Utility.nil_check(@encryptionKey),GrabzIt::Utility.b_to_str(@noAds),GrabzIt::Utility.nil_check(@post),GrabzIt::Utility.nil_check(@proxy),GrabzIt::Utility.nil_check(@address),GrabzIt::Utility.b_to_str(@noCookieNotifications))
|
141
|
+
|
142
|
+
return items.join("|")
|
143
|
+
end
|
144
|
+
|
145
|
+
# @!visibility private
|
146
|
+
def _getParameters(applicationKey, sig, callBackURL, dataName, dataValue)
|
147
|
+
params = createParameters(applicationKey, sig, callBackURL, dataName, dataValue)
|
148
|
+
params['bwidth'] = GrabzIt::Utility.nil_int_check(@browserWidth)
|
149
|
+
params['bheight'] = GrabzIt::Utility.nil_int_check(@browserHeight)
|
150
|
+
params['delay'] = GrabzIt::Utility.nil_int_check(@delay)
|
151
|
+
params['waitfor'] = GrabzIt::Utility.nil_check(@waitForElement)
|
152
|
+
params['requestmobileversion'] = GrabzIt::Utility.nil_int_check(@requestAs)
|
153
|
+
params['noads'] = GrabzIt::Utility.b_to_str(@noAds)
|
154
|
+
params['post'] = GrabzIt::Utility.nil_check(@post)
|
155
|
+
params['address'] = GrabzIt::Utility.nil_check(@address)
|
156
|
+
params['nonotify'] = GrabzIt::Utility.b_to_str(@noCookieNotifications)
|
157
|
+
|
158
|
+
return params
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
data/lib/grabzit/imageoptions.rb
CHANGED
@@ -23,6 +23,7 @@ module GrabzIt
|
|
23
23
|
@noCookieNotifications = false
|
24
24
|
@address = nil
|
25
25
|
@hd = false
|
26
|
+
@clickElement = nil
|
26
27
|
end
|
27
28
|
|
28
29
|
# @return [Integer] the width of the browser in pixels
|
@@ -140,6 +141,19 @@ module GrabzIt
|
|
140
141
|
# @return [void]
|
141
142
|
def waitForElement=(value)
|
142
143
|
@waitForElement = value
|
144
|
+
end
|
145
|
+
|
146
|
+
# @return [String] get the CSS selector of the HTML element in the web page that must clicked before the capture is performed
|
147
|
+
def clickElement
|
148
|
+
@clickElement
|
149
|
+
end
|
150
|
+
|
151
|
+
# Set the CSS selector of the HTML element in the web page that must clicked before the capture is performed
|
152
|
+
#
|
153
|
+
# @param value [String] the element to click
|
154
|
+
# @return [void]
|
155
|
+
def clickElement=(value)
|
156
|
+
@clickElement = value
|
143
157
|
end
|
144
158
|
|
145
159
|
# @return [Integer] get which user agent type should be used
|
@@ -263,7 +277,7 @@ module GrabzIt
|
|
263
277
|
items.push(GrabzIt::Utility.nil_check(url))
|
264
278
|
end
|
265
279
|
|
266
|
-
items.push(GrabzIt::Utility.nil_check(callBackURL),GrabzIt::Utility.nil_check(@format),GrabzIt::Utility.nil_int_check(@height),GrabzIt::Utility.nil_int_check(@width),GrabzIt::Utility.nil_int_check(@browserHeight),GrabzIt::Utility.nil_int_check(@browserWidth),GrabzIt::Utility.nil_check(@customId),GrabzIt::Utility.nil_int_check(@delay),GrabzIt::Utility.nil_check(@targetElement),GrabzIt::Utility.nil_check(@customWaterMarkId),GrabzIt::Utility.nil_int_check(@requestAs),GrabzIt::Utility.nil_check(@country),GrabzIt::Utility.nil_int_check(@quality),GrabzIt::Utility.nil_check(@hideElement),GrabzIt::Utility.nil_check(@exportURL),GrabzIt::Utility.nil_check(@waitForElement),GrabzIt::Utility.b_to_str(@transparent),GrabzIt::Utility.nil_check(@encryptionKey),GrabzIt::Utility.b_to_str(@noAds),GrabzIt::Utility.nil_check(@post),GrabzIt::Utility.nil_check(@proxy),GrabzIt::Utility.nil_check(@address),GrabzIt::Utility.b_to_str(@noCookieNotifications),GrabzIt::Utility.b_to_str(@hd))
|
280
|
+
items.push(GrabzIt::Utility.nil_check(callBackURL),GrabzIt::Utility.nil_check(@format),GrabzIt::Utility.nil_int_check(@height),GrabzIt::Utility.nil_int_check(@width),GrabzIt::Utility.nil_int_check(@browserHeight),GrabzIt::Utility.nil_int_check(@browserWidth),GrabzIt::Utility.nil_check(@customId),GrabzIt::Utility.nil_int_check(@delay),GrabzIt::Utility.nil_check(@targetElement),GrabzIt::Utility.nil_check(@customWaterMarkId),GrabzIt::Utility.nil_int_check(@requestAs),GrabzIt::Utility.nil_check(@country),GrabzIt::Utility.nil_int_check(@quality),GrabzIt::Utility.nil_check(@hideElement),GrabzIt::Utility.nil_check(@exportURL),GrabzIt::Utility.nil_check(@waitForElement),GrabzIt::Utility.b_to_str(@transparent),GrabzIt::Utility.nil_check(@encryptionKey),GrabzIt::Utility.b_to_str(@noAds),GrabzIt::Utility.nil_check(@post),GrabzIt::Utility.nil_check(@proxy),GrabzIt::Utility.nil_check(@address),GrabzIt::Utility.b_to_str(@noCookieNotifications),GrabzIt::Utility.b_to_str(@hd),GrabzIt::Utility.nil_check(@clickElement))
|
267
281
|
|
268
282
|
return items.join("|")
|
269
283
|
end
|
@@ -289,6 +303,7 @@ module GrabzIt
|
|
289
303
|
params['address'] = GrabzIt::Utility.nil_check(@address)
|
290
304
|
params['nonotify'] = GrabzIt::Utility.b_to_str(@noCookieNotifications)
|
291
305
|
params['hd'] = GrabzIt::Utility.b_to_str(@hd)
|
306
|
+
params['click'] = GrabzIt::Utility.nil_check(@clickElement)
|
292
307
|
|
293
308
|
return params
|
294
309
|
end
|
data/lib/grabzit/pdfoptions.rb
CHANGED
@@ -33,6 +33,9 @@ module GrabzIt
|
|
33
33
|
@mergeId = nil
|
34
34
|
@noCookieNotifications = false
|
35
35
|
@address = nil
|
36
|
+
@cssMediaType = nil
|
37
|
+
@password = nil
|
38
|
+
@clickElement = nil
|
36
39
|
end
|
37
40
|
|
38
41
|
# @return [Boolean] true if the background of the web page should be included in the PDF
|
@@ -74,7 +77,21 @@ module GrabzIt
|
|
74
77
|
def orientation=(value)
|
75
78
|
value = GrabzIt::Utility.nil_check(value).capitalize
|
76
79
|
@orientation = value
|
77
|
-
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# @return [String] the CSS Media Type of the PDF to be returned
|
83
|
+
def cssMediaType
|
84
|
+
@cssMediaType
|
85
|
+
end
|
86
|
+
|
87
|
+
# Set the CSS Media Type of the PDF to be returned: 'Print' or 'Screen'
|
88
|
+
#
|
89
|
+
# @param value [String] CSS Media Type
|
90
|
+
# @return [void]
|
91
|
+
def cssMediaType=(value)
|
92
|
+
value = GrabzIt::Utility.nil_check(value).capitalize
|
93
|
+
@cssMediaType = value
|
94
|
+
end
|
78
95
|
|
79
96
|
# @return [Boolean] true if the links should be included in the PDF
|
80
97
|
def includeLinks
|
@@ -322,6 +339,19 @@ module GrabzIt
|
|
322
339
|
def waitForElement=(value)
|
323
340
|
@waitForElement = value
|
324
341
|
end
|
342
|
+
|
343
|
+
# @return [String] get the CSS selector of the HTML element in the web page that must clicked before the capture is performed
|
344
|
+
def clickElement
|
345
|
+
@clickElement
|
346
|
+
end
|
347
|
+
|
348
|
+
# Set the CSS selector of the HTML element in the web page that must clicked before the capture is performed
|
349
|
+
#
|
350
|
+
# @param value [String] the element to click
|
351
|
+
# @return [void]
|
352
|
+
def clickElement=(value)
|
353
|
+
@clickElement = value
|
354
|
+
end
|
325
355
|
|
326
356
|
# @return [String] get the ID of a capture that should be merged at the beginning of the new PDF document
|
327
357
|
def mergeId
|
@@ -373,7 +403,20 @@ module GrabzIt
|
|
373
403
|
# @return [void]
|
374
404
|
def address=(value)
|
375
405
|
@address = value
|
376
|
-
end
|
406
|
+
end
|
407
|
+
|
408
|
+
# @return [String] get the password that protects the PDF document
|
409
|
+
def password
|
410
|
+
@password
|
411
|
+
end
|
412
|
+
|
413
|
+
# Set the password that protects the PDF document
|
414
|
+
#
|
415
|
+
# @param value [String] the password
|
416
|
+
# @return [void]
|
417
|
+
def password=(value)
|
418
|
+
@password = value
|
419
|
+
end
|
377
420
|
|
378
421
|
# Define a HTTP Post parameter and optionally value, this method can be called multiple times to add multiple parameters. Using this method will force
|
379
422
|
# GrabzIt to perform a HTTP post.
|
@@ -400,7 +443,7 @@ module GrabzIt
|
|
400
443
|
items.push(GrabzIt::Utility.nil_check(url))
|
401
444
|
end
|
402
445
|
|
403
|
-
items.push(GrabzIt::Utility.nil_check(callBackURL),GrabzIt::Utility.nil_check(@customId),GrabzIt::Utility.b_to_str(@includeBackground),@pagesize ,@orientation,GrabzIt::Utility.nil_check(@customWaterMarkId),GrabzIt::Utility.b_to_str(@includeLinks),GrabzIt::Utility.b_to_str(@includeOutline),GrabzIt::Utility.nil_check(@title),GrabzIt::Utility.nil_check(@coverURL),GrabzIt::Utility.nil_int_check(@marginTop),GrabzIt::Utility.nil_int_check(@marginLeft),GrabzIt::Utility.nil_int_check(@marginBottom),GrabzIt::Utility.nil_int_check(@marginRight),GrabzIt::Utility.nil_int_check(@delay),GrabzIt::Utility.nil_int_check(@requestAs),GrabzIt::Utility.nil_check(@country),GrabzIt::Utility.nil_int_check(@quality),GrabzIt::Utility.nil_check(@templateId),GrabzIt::Utility.nil_check(@hideElement),GrabzIt::Utility.nil_check(@targetElement),GrabzIt::Utility.nil_check(@exportURL),GrabzIt::Utility.nil_check(@waitForElement),GrabzIt::Utility.nil_check(@encryptionKey),GrabzIt::Utility.b_to_str(@noAds),GrabzIt::Utility.nil_check(@post),GrabzIt::Utility.nil_int_check(@browserWidth),GrabzIt::Utility.nil_int_check(@height),GrabzIt::Utility.nil_int_check(@width),GrabzIt::Utility.nil_check(@templateVariables),GrabzIt::Utility.nil_check(@proxy),GrabzIt::Utility.nil_check(@mergeId),GrabzIt::Utility.nil_check(@address),GrabzIt::Utility.b_to_str(@noCookieNotifications))
|
446
|
+
items.push(GrabzIt::Utility.nil_check(callBackURL),GrabzIt::Utility.nil_check(@customId),GrabzIt::Utility.b_to_str(@includeBackground),@pagesize ,@orientation,GrabzIt::Utility.nil_check(@customWaterMarkId),GrabzIt::Utility.b_to_str(@includeLinks),GrabzIt::Utility.b_to_str(@includeOutline),GrabzIt::Utility.nil_check(@title),GrabzIt::Utility.nil_check(@coverURL),GrabzIt::Utility.nil_int_check(@marginTop),GrabzIt::Utility.nil_int_check(@marginLeft),GrabzIt::Utility.nil_int_check(@marginBottom),GrabzIt::Utility.nil_int_check(@marginRight),GrabzIt::Utility.nil_int_check(@delay),GrabzIt::Utility.nil_int_check(@requestAs),GrabzIt::Utility.nil_check(@country),GrabzIt::Utility.nil_int_check(@quality),GrabzIt::Utility.nil_check(@templateId),GrabzIt::Utility.nil_check(@hideElement),GrabzIt::Utility.nil_check(@targetElement),GrabzIt::Utility.nil_check(@exportURL),GrabzIt::Utility.nil_check(@waitForElement),GrabzIt::Utility.nil_check(@encryptionKey),GrabzIt::Utility.b_to_str(@noAds),GrabzIt::Utility.nil_check(@post),GrabzIt::Utility.nil_int_check(@browserWidth),GrabzIt::Utility.nil_int_check(@height),GrabzIt::Utility.nil_int_check(@width),GrabzIt::Utility.nil_check(@templateVariables),GrabzIt::Utility.nil_check(@proxy),GrabzIt::Utility.nil_check(@mergeId),GrabzIt::Utility.nil_check(@address),GrabzIt::Utility.b_to_str(@noCookieNotifications),GrabzIt::Utility.nil_check(@cssMediaType),GrabzIt::Utility.nil_check(@password),GrabzIt::Utility.nil_check(@clickElement))
|
404
447
|
|
405
448
|
return items.join("|")
|
406
449
|
end
|
@@ -436,7 +479,10 @@ module GrabzIt
|
|
436
479
|
params['mergeid'] = GrabzIt::Utility.nil_check(@mergeId)
|
437
480
|
params['address'] = GrabzIt::Utility.nil_check(@address)
|
438
481
|
params['nonotify'] = GrabzIt::Utility.b_to_str(@noCookieNotifications)
|
439
|
-
|
482
|
+
params['media'] = GrabzIt::Utility.nil_check(@cssMediaType)
|
483
|
+
params['password'] = GrabzIt::Utility.nil_check(@password)
|
484
|
+
params['click'] = GrabzIt::Utility.nil_check(@clickElement)
|
485
|
+
|
440
486
|
return params;
|
441
487
|
end
|
442
488
|
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.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GrabzIt
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -24,11 +24,11 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description: Use GrabzIt to convert HTML or URL's into images, PDF
|
28
|
-
These captures have highly customizable options include altering quality,
|
29
|
-
size, browser type, geographic location and much more. Additionally GrabzIt
|
30
|
-
even convert HTML tables on the web into a CSV or Excel spreadsheet. As well
|
31
|
-
enabling online video's to be converted into animated GIF's.
|
27
|
+
description: Use GrabzIt to convert HTML or URL's into images, PDF, rendered HTML
|
28
|
+
or DOCX. These captures have highly customizable options include altering quality,
|
29
|
+
delay, size, browser type, geographic location and much more. Additionally GrabzIt
|
30
|
+
can even convert HTML tables on the web into a CSV or Excel spreadsheet. As well
|
31
|
+
as enabling online video's to be converted into animated GIF's.
|
32
32
|
email: support@grabz.it
|
33
33
|
executables: []
|
34
34
|
extensions: []
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- lib/grabzit/cookie.rb
|
43
43
|
- lib/grabzit/docxoptions.rb
|
44
44
|
- lib/grabzit/exception.rb
|
45
|
+
- lib/grabzit/htmloptions.rb
|
45
46
|
- lib/grabzit/imageoptions.rb
|
46
47
|
- lib/grabzit/pdfoptions.rb
|
47
48
|
- lib/grabzit/proxy.rb
|
@@ -56,7 +57,7 @@ homepage: https://grabz.it/api/ruby
|
|
56
57
|
licenses:
|
57
58
|
- MIT
|
58
59
|
metadata: {}
|
59
|
-
post_install_message:
|
60
|
+
post_install_message:
|
60
61
|
rdoc_options: []
|
61
62
|
require_paths:
|
62
63
|
- lib
|
@@ -71,9 +72,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
72
|
- !ruby/object:Gem::Version
|
72
73
|
version: '0'
|
73
74
|
requirements: []
|
74
|
-
|
75
|
-
|
76
|
-
signing_key:
|
75
|
+
rubygems_version: 3.1.6
|
76
|
+
signing_key:
|
77
77
|
specification_version: 4
|
78
78
|
summary: GrabzIt Ruby Client
|
79
79
|
test_files: []
|