urlkit 1.0.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 +7 -0
- data/LICENSE +21 -0
- data/README.md +82 -0
- data/lib/urlkit.rb +17 -0
- data/urlkit.gemspec +12 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3c01849efef01a221786b63d39aa7f98750db719
|
4
|
+
data.tar.gz: 741380265c598a9a91adf4ba5c693914efcbe932
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f9fe27f07812a6ea3a28c74bcdf85a2eeff748d5815a8af95a43a9ec2297b5a7640e0e181354b45a95f7302ef141162db796ef1a09ddf236b5e979f984dafc88
|
7
|
+
data.tar.gz: dbd0b5068712cf46a784d10345e5f6990c217a672aea35ecdf180bb08e76da987958aa7d403f415e61ee8c7712ea98218103175ea21f44c9b82faa3e46cc878f
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 UrlKit
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
[](https://travis-ci.org/UrlKit/urlkit-ruby)
|
2
|
+
|
3
|
+
|
4
|
+
# UrlKit
|
5
|
+
|
6
|
+
## Perfect Screenshots Anywhere
|
7
|
+
|
8
|
+
Get high quality screenshots using a real browser in seconds using our reliable CDN backed service
|
9
|
+
|
10
|
+
## Requirements
|
11
|
+
|
12
|
+
Works with Ruby 1.x 2.x and Jruby
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Install via gem
|
17
|
+
|
18
|
+
```bash
|
19
|
+
gem install urlkit
|
20
|
+
```
|
21
|
+
|
22
|
+
Once installed you can generate screenshots as follows:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
from urlkit import UrlKit
|
26
|
+
|
27
|
+
urlkit = UrlKit.new('URLKIT_KEY', 'URLKIT_SECRET')
|
28
|
+
|
29
|
+
screenshotUrl = urlkit.screenshotUrl({
|
30
|
+
"url": "bbc.com/news",
|
31
|
+
"width": 800
|
32
|
+
})
|
33
|
+
```
|
34
|
+
|
35
|
+
## Parameters
|
36
|
+
|
37
|
+
These are the options you can use to customize your screenshot.
|
38
|
+
|
39
|
+
| Parameter | Default | Description |
|
40
|
+
| --- | --- | --- |
|
41
|
+
| url | | **Required.** The website address that you want to take a screenshot of. |
|
42
|
+
| width | 1920 | Width of the thumbnail. |
|
43
|
+
| viewport_width | 1920 | Width of the browser viewport this is the actual width of the page before we resize it for the thumbnail. |
|
44
|
+
| viewport_height | (1200) | Height of the browser viewport, if you do not give this parameter we will calculate it for you based on viewport_width in 16:10 ratio. |
|
45
|
+
| full_page | false | Capture a full length screenshot of the requested page. |
|
46
|
+
| delay | 250 | Amount of time to wait before taking a screenshot of the page after it is fully loaded. Maximum 120000ms (2 minutes), minimum 250ms. |
|
47
|
+
| cache_time | 2592000 | Amount of time in milliseconds to wait before taking the screenshot again. Maximum 2592000ms (30 days), minimum 1ms. |
|
48
|
+
| user_agent | Latest Firefox User Agent | Set the user agent this screenshot will identify as. Useful for identifying as a mobile or tablet browser or to identify as a specific browser if the website pretends it needs Internet Explorer to view it's contents. |
|
49
|
+
| language | false | Trim the outer color of the screenshot, useful for SVG's. |
|
50
|
+
| transparent | false | Remove the background from the page, PNG format required. |
|
51
|
+
| language | en | Accept-Language header customization for websites that support it, set ja for Japanese, de for German etc. |
|
52
|
+
| cookie | | Semi colon separated list of cookies e.g. fruit=apple; drink=tea |
|
53
|
+
| disable_javascript | false | Don't execute javascript on this page. |
|
54
|
+
| disable_images | false | Don't download images on this page. |
|
55
|
+
| timeout | 300000 | Amount of time in milliseconds to wait before taking screenshot anyway. Maximum 300000ms (5 minutes). |
|
56
|
+
| mobile | false | Shortcut to set pixel_ratio, user_agent, viewport_width, viewport_height and width to that of the latest iPhone. |
|
57
|
+
| pixel_ratio | 1 | Multiplier that sets the pixel density of the page relative to the resolution, useful for taking retina screenshots (2). |
|
58
|
+
| format | png | Output the screenshot as a PNG (png) or JPEG (jpg) image. |
|
59
|
+
| quality | 92 (if format=jpg) | Set the jpeg quality of the screenshot if jpeg is set as the format. |
|
60
|
+
| click_selector | | Accepts valid DOM selector (#wantedselector). Rendered screenshot will only display contents of DOM selector. |
|
61
|
+
| wait_selector | | Accepts valid DOM selector (.valid_selector > .another_class). We will not take the screenshot until .valid_selector appears on this screen and is not display:none; or timeout is reached. |
|
62
|
+
| clip_selector | | Accepts valid DOM selector (.valid_selector:not(div)). Rendered screenshot will only display contents of DOM selector. |
|
63
|
+
|
64
|
+
More documentation about this package and other language implementations can be found at https://urlk.it/documentation.
|
65
|
+
|
66
|
+
## Support
|
67
|
+
|
68
|
+
Contact us at support@brushd.com if you have any issues or questions about this package.
|
69
|
+
|
70
|
+
## Other implementations
|
71
|
+
|
72
|
+
Need an implementation for another language?
|
73
|
+
|
74
|
+
| Language | Address |
|
75
|
+
| --- | --- |
|
76
|
+
| C# | https://github.com/UrlKit/urlkit-cs |
|
77
|
+
| Java | https://github.com/UrlKit/urlkit-java |
|
78
|
+
| Node.js |https://github.com/UrlKit/urlkit-node |
|
79
|
+
| PHP | https://github.com/UrlKit/urlkit-php |
|
80
|
+
| Python |https://github.com/UrlKit/urlkit-python |
|
81
|
+
| Ruby | https://github.com/UrlKit/urlkit-ruby |
|
82
|
+
| Shell Script | https://github.com/UrlKit/urlkit-sh |
|
data/lib/urlkit.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
class UrlKit
|
5
|
+
def initialize(apiKey, apiSecret)
|
6
|
+
@apiKey = apiKey
|
7
|
+
@apiSecret = apiSecret
|
8
|
+
end
|
9
|
+
|
10
|
+
def screenshotUrl(options={})
|
11
|
+
parameters = options.map {|option| option.map {|value| URI.escape(value.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) }.join('=') }.join('&')
|
12
|
+
|
13
|
+
token = OpenSSL::HMAC.hexdigest('sha1', @apiSecret, parameters)
|
14
|
+
|
15
|
+
"https://api.urlk.it/v1/screenshot/#{@apiKey}/#{token}?#{parameters}"
|
16
|
+
end
|
17
|
+
end
|
data/urlkit.gemspec
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = 'urlkit'
|
3
|
+
spec.version = '1.0.0'
|
4
|
+
spec.date = '2017-05-01'
|
5
|
+
spec.summary = "Get high quality screenshots using a real browser in seconds using our reliable CDN backed service"
|
6
|
+
spec.description = "UrlKit ruby screenshot generator"
|
7
|
+
spec.authors = ["Chris Hutchinson"]
|
8
|
+
spec.email = 'chris@brushd.com'
|
9
|
+
spec.files = %w(LICENSE README.md urlkit.gemspec) + Dir['lib/*.rb']
|
10
|
+
spec.homepage = 'https://urlk.it/'
|
11
|
+
spec.license = 'MIT'
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: urlkit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Hutchinson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: UrlKit ruby screenshot generator
|
14
|
+
email: chris@brushd.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- LICENSE
|
20
|
+
- README.md
|
21
|
+
- urlkit.gemspec
|
22
|
+
- lib/urlkit.rb
|
23
|
+
homepage: https://urlk.it/
|
24
|
+
licenses:
|
25
|
+
- MIT
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 2.0.14.1
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: Get high quality screenshots using a real browser in seconds using our reliable
|
47
|
+
CDN backed service
|
48
|
+
test_files: []
|