grabzit 3.5.2 → 3.5.3
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 +4 -4
- data/lib/grabzit/client.rb +44 -3
- data/lib/grabzit/videooptions.rb +240 -0
- data/test/test_grabzit.rb +9 -1
- metadata +6 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 69441e35b5c040ac5be4e771f9d984bb6b29bff4914a93e64ce8973035aea3c4
|
|
4
|
+
data.tar.gz: 26678eafcbaa717bfb3944c9e5ba5be280d8c0818263f037c88fd352b33e4b2e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e75ae31a753d25f5e7205a062b3deab0fbb71cf9277db09e8b5b5113a5e12cb0f52faa70d41a02bc580cc50b5c3cdaf392bc4e5afbc68822d1f5d25ffa9b9a2b
|
|
7
|
+
data.tar.gz: 812617ee29f875014791ab34c17d4de73660eca023bea8cd0a5506472d3c8a479d10d78a3bdc83cddbe05b92699c61c7f1f3f7aa5e9f4e126cbc099b6da0b6ff
|
data/lib/grabzit/client.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# The public REST API for
|
|
1
|
+
# The public REST API for https://grabz.it
|
|
2
2
|
# @example To include the GrabzIt module do the following
|
|
3
3
|
# require 'grabzit'
|
|
4
4
|
module GrabzIt
|
|
@@ -32,13 +32,15 @@ module GrabzIt
|
|
|
32
32
|
# grabzItClient.save("http://www.mysite.com/grabzit/handler")
|
|
33
33
|
# @version 3.0
|
|
34
34
|
# @author GrabzIt
|
|
35
|
-
# @see
|
|
35
|
+
# @see https://grabz.it/api/ruby/ GrabzIt Ruby API
|
|
36
36
|
class Client
|
|
37
37
|
|
|
38
38
|
WebServicesBaseURL = "://api.grabz.it/services/"
|
|
39
39
|
private_constant :WebServicesBaseURL
|
|
40
40
|
TakePicture = "takepicture"
|
|
41
41
|
private_constant :TakePicture
|
|
42
|
+
TakeVideo = "takevideo"
|
|
43
|
+
private_constant :TakeVideo
|
|
42
44
|
TakeTable = "taketable"
|
|
43
45
|
private_constant :TakeTable
|
|
44
46
|
TakePDF = "takepdf"
|
|
@@ -54,7 +56,7 @@ module GrabzIt
|
|
|
54
56
|
#
|
|
55
57
|
# @param applicationKey [String] your application key
|
|
56
58
|
# @param applicationSecret [String] your application secret
|
|
57
|
-
# @see
|
|
59
|
+
# @see https://grabz.it/login/create/ You can get an application key and secret by registering for free with GrabzIt
|
|
58
60
|
def initialize(applicationKey, applicationSecret)
|
|
59
61
|
@applicationKey = applicationKey
|
|
60
62
|
@applicationSecret = applicationSecret
|
|
@@ -116,6 +118,45 @@ module GrabzIt
|
|
|
116
118
|
html_to_image(read_file(path), options)
|
|
117
119
|
end
|
|
118
120
|
|
|
121
|
+
# This method specifies the URL that should be converted into a video
|
|
122
|
+
#
|
|
123
|
+
# @param url [String] the URL to capture as a video
|
|
124
|
+
# @param options [VideoOptions, nil] a instance of the VideoOptions class that defines any special options to use when creating a video
|
|
125
|
+
# @return [void]
|
|
126
|
+
def url_to_video(url, options = nil)
|
|
127
|
+
|
|
128
|
+
if options == nil
|
|
129
|
+
options = VideoOptions.new()
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
@request = Request.new(@protocol + WebServicesBaseURL + TakeVideo, false, options, url)
|
|
133
|
+
return nil
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# This method specifies the HTML that should be converted into a video
|
|
137
|
+
#
|
|
138
|
+
# @param html [String] the HTML to convert into a video
|
|
139
|
+
# @param options [VideoOptions, nil] a instance of the VideoOptions class that defines any special options to use when creating a video
|
|
140
|
+
# @return [void]
|
|
141
|
+
def html_to_video(html, options = nil)
|
|
142
|
+
|
|
143
|
+
if options == nil
|
|
144
|
+
options = VideoOptions.new()
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
@request = Request.new(@protocol + WebServicesBaseURL + TakeVideo, true, options, html)
|
|
148
|
+
return nil
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# This method specifies a HTML file that should be converted into a video
|
|
152
|
+
#
|
|
153
|
+
# @param path [String] the file path of a HTML file to convert into a video
|
|
154
|
+
# @param options [VideoOptions, nil] a instance of the VideoOptions class that defines any special options to use when creating a video
|
|
155
|
+
# @return [void]
|
|
156
|
+
def file_to_video(path, options = nil)
|
|
157
|
+
html_to_video(read_file(path), options)
|
|
158
|
+
end
|
|
159
|
+
|
|
119
160
|
# This method specifies the URL that should be converted into rendered HTML
|
|
120
161
|
#
|
|
121
162
|
# @param url [String] the URL to capture as rendered HTML
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
module GrabzIt
|
|
2
|
+
require File.join(File.dirname(__FILE__), 'baseoptions')
|
|
3
|
+
|
|
4
|
+
# Represents all of the options available when creating an video
|
|
5
|
+
# @version 3.0
|
|
6
|
+
# @author GrabzIt
|
|
7
|
+
class VideoOptions < BaseOptions
|
|
8
|
+
def initialize()
|
|
9
|
+
super()
|
|
10
|
+
@browserWidth = nil
|
|
11
|
+
@browserHeight = nil
|
|
12
|
+
@waitForElement = nil
|
|
13
|
+
@requestAs = 0
|
|
14
|
+
@customWaterMarkId = nil
|
|
15
|
+
@noAds = false
|
|
16
|
+
@noCookieNotifications = false
|
|
17
|
+
@address = nil
|
|
18
|
+
@clickElement = nil
|
|
19
|
+
@start = 0
|
|
20
|
+
@duration = 10
|
|
21
|
+
@framesPerSecond = 0
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# @return [Integer] the width of the browser in pixels
|
|
25
|
+
def browserWidth
|
|
26
|
+
@browserWidth
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Set the width of the browser in pixels
|
|
30
|
+
#
|
|
31
|
+
# @param value [Integer] the browser width
|
|
32
|
+
# @return [void]
|
|
33
|
+
def browserWidth=(value)
|
|
34
|
+
@browserWidth = value
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @return [Integer] the height of the browser in pixels
|
|
38
|
+
def browserHeight
|
|
39
|
+
@browserHeight
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Set the height of the browser in pixels. Use -1 to screenshot the whole web page
|
|
43
|
+
#
|
|
44
|
+
# @param value [Integer] the browser height
|
|
45
|
+
# @return [void]
|
|
46
|
+
def browserHeight=(value)
|
|
47
|
+
@browserHeight = value
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# @return [String] get the CSS selector of the HTML element in the web page that must be visible before the capture is performed
|
|
51
|
+
def waitForElement
|
|
52
|
+
@waitForElement
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Set the CSS selector of the HTML element in the web page that must be visible before the capture is performed
|
|
56
|
+
#
|
|
57
|
+
# @param value [String] the element to wait for
|
|
58
|
+
# @return [void]
|
|
59
|
+
def waitForElement=(value)
|
|
60
|
+
@waitForElement = value
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# @return [String] get the CSS selector of the HTML element in the web page that must clicked before the capture is performed
|
|
64
|
+
def clickElement
|
|
65
|
+
@clickElement
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Set the CSS selector of the HTML element in the web page that must clicked before the capture is performed
|
|
69
|
+
#
|
|
70
|
+
# @param value [String] the element to click
|
|
71
|
+
# @return [void]
|
|
72
|
+
def clickElement=(value)
|
|
73
|
+
@clickElement = value
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# @return [Integer] get which user agent type should be used
|
|
77
|
+
def requestAs
|
|
78
|
+
@requestAs
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Set which user agent type should be used: Standard Browser = 0, Mobile Browser = 1, Search Engine = 2 and Fallback Browser = 3
|
|
82
|
+
#
|
|
83
|
+
# @param value [Integer] the browser type
|
|
84
|
+
# @return [void]
|
|
85
|
+
def requestAs=(value)
|
|
86
|
+
@requestAs = value
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# @return [String] the custom watermark id.
|
|
90
|
+
def customWaterMarkId
|
|
91
|
+
@customWaterMarkId
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Set a custom watermark to add to the screenshot.
|
|
95
|
+
#
|
|
96
|
+
# @param value [String] custom watermark id
|
|
97
|
+
# @return [void]
|
|
98
|
+
def customWaterMarkId=(value)
|
|
99
|
+
@customWaterMarkId = value
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# @return [Boolean] get if adverts should be automatically hidden
|
|
103
|
+
def noAds
|
|
104
|
+
@noAds
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Set to true if adverts should be automatically hidden
|
|
108
|
+
#
|
|
109
|
+
# @param value [Boolean] hide adverts
|
|
110
|
+
# @return [void]
|
|
111
|
+
def noAds=(value)
|
|
112
|
+
@noAds = value
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# @return [Boolean] get if cookie notifications should be automatically hidden
|
|
116
|
+
def noCookieNotifications
|
|
117
|
+
@noCookieNotifications
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Set to true if cookie notifications should be automatically hidden
|
|
121
|
+
#
|
|
122
|
+
# @param value [Boolean] hide cookie notifications
|
|
123
|
+
# @return [void]
|
|
124
|
+
def noCookieNotifications=(value)
|
|
125
|
+
@noCookieNotifications = value
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# @return [String] get the URL to execute the HTML code in
|
|
129
|
+
def address
|
|
130
|
+
@address
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Set the URL to execute the HTML code in
|
|
134
|
+
#
|
|
135
|
+
# @param value [String] the address
|
|
136
|
+
# @return [void]
|
|
137
|
+
def address=(value)
|
|
138
|
+
@address = value
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# @return [Integer] the starting time of the web page that should be converted into a video
|
|
142
|
+
def start
|
|
143
|
+
@start
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Set the starting time of the web page that should be converted into a video
|
|
147
|
+
#
|
|
148
|
+
# @param value [Integer] the second to start at
|
|
149
|
+
# @return [void]
|
|
150
|
+
def start=(value)
|
|
151
|
+
@start = value
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# @return [Integer] the length in seconds of the web page that should be converted into a video
|
|
155
|
+
def duration
|
|
156
|
+
@duration
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Set the length in seconds of the web page that should be converted into a video
|
|
160
|
+
#
|
|
161
|
+
# @param value [Integer] the number of seconds
|
|
162
|
+
# @return [void]
|
|
163
|
+
def duration=(value)
|
|
164
|
+
@duration = value
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# @return [Float] the number of frames per second that should be used to create the video. From a minimum of 0.2 to a maximum of 10
|
|
168
|
+
def framesPerSecond
|
|
169
|
+
@framesPerSecond
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Set the number of frames per second that should be used to create the video. From a minimum of 0.2 to a maximum of 10
|
|
173
|
+
#
|
|
174
|
+
# @param value [Float] the number of frames per second
|
|
175
|
+
# @return [void]
|
|
176
|
+
def framesPerSecond=(value)
|
|
177
|
+
@framesPerSecond = value
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Define a HTTP Post parameter and optionally value, this method can be called multiple times to add multiple parameters. Using this method will force
|
|
181
|
+
# GrabzIt to perform a HTTP post.
|
|
182
|
+
#
|
|
183
|
+
# @param name [String] the name of the HTTP Post parameter
|
|
184
|
+
# @param value [String] the value of the HTTP Post parameter
|
|
185
|
+
def add_post_parameter(name, value)
|
|
186
|
+
@post = appendParameter(@post, name, value)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# @!visibility private
|
|
190
|
+
def _getSignatureString(applicationSecret, callBackURL, url = nil)
|
|
191
|
+
items = [applicationSecret]
|
|
192
|
+
|
|
193
|
+
if(url != nil)
|
|
194
|
+
items.push(GrabzIt::Utility.nil_check(url))
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
items.push(GrabzIt::Utility.nil_check(callBackURL),
|
|
198
|
+
GrabzIt::Utility.nil_int_check(@browserHeight),
|
|
199
|
+
GrabzIt::Utility.nil_int_check(@browserWidth),
|
|
200
|
+
GrabzIt::Utility.nil_check(@customId),
|
|
201
|
+
GrabzIt::Utility.nil_check(@customWaterMarkId),
|
|
202
|
+
GrabzIt::Utility.nil_int_check(@start),
|
|
203
|
+
GrabzIt::Utility.nil_int_check(@requestAs),
|
|
204
|
+
GrabzIt::Utility.nil_check(@country),
|
|
205
|
+
GrabzIt::Utility.nil_check(@exportURL),
|
|
206
|
+
GrabzIt::Utility.nil_check(@waitForElement),
|
|
207
|
+
GrabzIt::Utility.nil_check(@encryptionKey),
|
|
208
|
+
GrabzIt::Utility.b_to_str(@noAds),
|
|
209
|
+
GrabzIt::Utility.nil_check(@post),
|
|
210
|
+
GrabzIt::Utility.nil_check(@proxy),
|
|
211
|
+
GrabzIt::Utility.nil_check(@address),
|
|
212
|
+
GrabzIt::Utility.b_to_str(@noCookieNotifications),
|
|
213
|
+
GrabzIt::Utility.nil_check(@clickElement),
|
|
214
|
+
GrabzIt::Utility.nil_float_check(@framesPerSecond),
|
|
215
|
+
GrabzIt::Utility.nil_int_check(@duration))
|
|
216
|
+
|
|
217
|
+
return items.join("|")
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# @!visibility private
|
|
221
|
+
def _getParameters(applicationKey, sig, callBackURL, dataName, dataValue)
|
|
222
|
+
params = createParameters(applicationKey, sig, callBackURL, dataName, dataValue)
|
|
223
|
+
params['bwidth'] = GrabzIt::Utility.nil_int_check(@browserWidth)
|
|
224
|
+
params['customwatermarkid'] = GrabzIt::Utility.nil_check(@customWaterMarkId)
|
|
225
|
+
params['bheight'] = GrabzIt::Utility.nil_int_check(@browserHeight)
|
|
226
|
+
params['waitfor'] = GrabzIt::Utility.nil_check(@waitForElement)
|
|
227
|
+
params['requestmobileversion'] = GrabzIt::Utility.nil_int_check(@requestAs)
|
|
228
|
+
params['noads'] = GrabzIt::Utility.b_to_str(@noAds)
|
|
229
|
+
params['post'] = GrabzIt::Utility.nil_check(@post)
|
|
230
|
+
params['address'] = GrabzIt::Utility.nil_check(@address)
|
|
231
|
+
params['nonotify'] = GrabzIt::Utility.b_to_str(@noCookieNotifications)
|
|
232
|
+
params['click'] = GrabzIt::Utility.nil_check(@clickElement)
|
|
233
|
+
params['start'] = GrabzIt::Utility.nil_int_check(@start)
|
|
234
|
+
params['fps'] = GrabzIt::Utility.nil_float_check(@framesPerSecond)
|
|
235
|
+
params['duration'] = GrabzIt::Utility.nil_int_check(@duration)
|
|
236
|
+
|
|
237
|
+
return params
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
end
|
data/test/test_grabzit.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'test/unit'
|
|
2
|
-
|
|
2
|
+
require_relative '../lib/grabzit.rb'
|
|
3
3
|
|
|
4
4
|
class GrabzItTest < Test::Unit::TestCase
|
|
5
5
|
Cookie_Name = "test_cookie"
|
|
@@ -31,6 +31,14 @@ class GrabzItTest < Test::Unit::TestCase
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
def test_html_to_video
|
|
35
|
+
assert_nothing_raised "An error occured when trying to take convert HTML to a video" do
|
|
36
|
+
grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
|
|
37
|
+
grabzItClient.html_to_video("<h1>Hello world</h1>");
|
|
38
|
+
assert_not_equal(false, grabzItClient.save(), "HTML not converted")
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
34
42
|
def test_html_to_pdf
|
|
35
43
|
assert_nothing_raised "An error occured when trying to take convert HTML to a pdf" do
|
|
36
44
|
grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
|
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.5.
|
|
4
|
+
version: 3.5.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- GrabzIt
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-02-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -24,8 +24,8 @@ 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, rendered
|
|
28
|
-
or DOCX. These captures have highly customizable options include altering quality,
|
|
27
|
+
description: Use GrabzIt to convert HTML or URL's into images, PDF, videos, rendered
|
|
28
|
+
HTML or DOCX. These captures have highly customizable options include altering quality,
|
|
29
29
|
delay, size, browser type, geographic location and much more. Additionally GrabzIt
|
|
30
30
|
can even convert HTML tables on the web into a CSV or Excel spreadsheet. As well
|
|
31
31
|
as enabling online video's to be converted into animated GIF's.
|
|
@@ -50,6 +50,7 @@ files:
|
|
|
50
50
|
- lib/grabzit/screenshotstatus.rb
|
|
51
51
|
- lib/grabzit/tableoptions.rb
|
|
52
52
|
- lib/grabzit/utility.rb
|
|
53
|
+
- lib/grabzit/videooptions.rb
|
|
53
54
|
- lib/grabzit/watermark.rb
|
|
54
55
|
- test/test.png
|
|
55
56
|
- test/test_grabzit.rb
|
|
@@ -72,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
72
73
|
- !ruby/object:Gem::Version
|
|
73
74
|
version: '0'
|
|
74
75
|
requirements: []
|
|
75
|
-
rubygems_version: 3.
|
|
76
|
+
rubygems_version: 3.4.19
|
|
76
77
|
signing_key:
|
|
77
78
|
specification_version: 4
|
|
78
79
|
summary: GrabzIt Ruby Client
|