screenshotscout 0.7.0 → 0.8.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 +4 -4
- data/README.md +2 -19
- data/lib/screenshotscout/capture_values.rb +1 -0
- data/lib/screenshotscout/client.rb +4 -1
- data/lib/screenshotscout/responses.rb +4 -3
- data/lib/screenshotscout/version.rb +1 -1
- data/sig/screenshotscout.rbs +4 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f351eba8ddd250b731eed37a118b35ef83eea64858935fdfd1e337070f43e273
|
|
4
|
+
data.tar.gz: f4ea9b43805d65a41365b158036fa3e4173113bb682b3ac69c45caea820fb994
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cd80442d19032f609e2c5c69a2dfec05e144eb503b66639bf9c05b82248aa0512d182f8c2eed69a1654f70cc82d5f2b6c38c7b2c1702cd75f91f449bc8b8464f
|
|
7
|
+
data.tar.gz: 0e92ecac62c689cc814376be3186a42a8778bf52b9117733602a0893cc1fd38483ded798a20df07445bb392eccbd09e06a3442112f3dbfc1ac5c0f3805a2a7c0
|
data/README.md
CHANGED
|
@@ -51,29 +51,12 @@ puts response.screenshot_url
|
|
|
51
51
|
|
|
52
52
|
`capture` uses POST by default, or GET when the client has a secret key. It returns a
|
|
53
53
|
`BinaryCaptureResponse` when `response_type` is omitted or set to `CaptureResponseType::BINARY`.
|
|
54
|
-
|
|
55
|
-
## Get a page as Markdown
|
|
56
|
-
|
|
57
|
-
Set `format` to `CaptureFormat::MD` to get the page as Markdown:
|
|
58
|
-
|
|
59
|
-
```ruby
|
|
60
|
-
require "screenshotscout"
|
|
61
|
-
|
|
62
|
-
client = ScreenshotScout::Client.new # Reads SCREENSHOTSCOUT_ACCESS_KEY
|
|
63
|
-
response = client.capture(
|
|
64
|
-
"https://example.com",
|
|
65
|
-
ScreenshotScout::CaptureOptions.new(format: ScreenshotScout::CaptureFormat::MD)
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
File.write("page.md", response.markdown)
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
`markdown` returns the Markdown text as a UTF-8 string, or `nil` for other formats.
|
|
54
|
+
With `CaptureFormat::MD` or `CaptureFormat::HTML`, the text is also in `markdown` or `html`.
|
|
72
55
|
|
|
73
56
|
## Request a JSON result
|
|
74
57
|
|
|
75
58
|
Set `response_type` to `CaptureResponseType::JSON` to receive capture metadata instead of binary
|
|
76
|
-
image, PDF, or
|
|
59
|
+
image, PDF, Markdown, or HTML output:
|
|
77
60
|
|
|
78
61
|
```ruby
|
|
79
62
|
require "screenshotscout"
|
|
@@ -174,7 +174,8 @@ module ScreenshotScout
|
|
|
174
174
|
screenshot_url: raw_response.header("Screenshot-Scout-Screenshot-URL").first,
|
|
175
175
|
screenshot_url_expires_at: raw_response.header("Screenshot-Scout-Screenshot-URL-Expires-At").first,
|
|
176
176
|
cache_status: raw_response.header("Screenshot-Scout-Cache-Status").first,
|
|
177
|
-
markdown: markdown_media_type?(raw_response.content_type) ? utf8_text(raw_response.body) : nil
|
|
177
|
+
markdown: markdown_media_type?(raw_response.content_type) ? utf8_text(raw_response.body) : nil,
|
|
178
|
+
html: html_media_type?(raw_response.content_type) ? utf8_text(raw_response.body) : nil
|
|
178
179
|
)
|
|
179
180
|
end
|
|
180
181
|
|
|
@@ -253,6 +254,8 @@ module ScreenshotScout
|
|
|
253
254
|
|
|
254
255
|
def markdown_media_type?(content_type) = content_type.to_s.partition(";").first.strip.downcase == "text/markdown"
|
|
255
256
|
|
|
257
|
+
def html_media_type?(content_type) = content_type.to_s.partition(";").first.strip.downcase == "text/html"
|
|
258
|
+
|
|
256
259
|
def utf8_text(bytes) = bytes.dup.force_encoding(Encoding::UTF_8).scrub
|
|
257
260
|
|
|
258
261
|
private_constant :ACCESS_KEY_PATTERN
|
|
@@ -43,17 +43,18 @@ module ScreenshotScout
|
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
# Successful binary capture, including response metadata and image, PDF, or
|
|
46
|
+
# Successful binary capture, including response metadata and image, PDF, Markdown, or HTML bytes.
|
|
47
47
|
class BinaryCaptureResponse < CaptureResponse
|
|
48
|
-
attr_reader :bytes, :screenshot_url, :screenshot_url_expires_at, :cache_status, :markdown
|
|
48
|
+
attr_reader :bytes, :screenshot_url, :screenshot_url_expires_at, :cache_status, :markdown, :html
|
|
49
49
|
|
|
50
|
-
def initialize(raw_response:, screenshot_url:, screenshot_url_expires_at:, cache_status:, markdown: nil)
|
|
50
|
+
def initialize(raw_response:, screenshot_url:, screenshot_url_expires_at:, cache_status:, markdown: nil, html: nil)
|
|
51
51
|
super(raw_response: raw_response)
|
|
52
52
|
@bytes = raw_response.body
|
|
53
53
|
@screenshot_url = screenshot_url
|
|
54
54
|
@screenshot_url_expires_at = screenshot_url_expires_at
|
|
55
55
|
@cache_status = cache_status
|
|
56
56
|
@markdown = markdown
|
|
57
|
+
@html = html
|
|
57
58
|
freeze
|
|
58
59
|
end
|
|
59
60
|
end
|
data/sig/screenshotscout.rbs
CHANGED
|
@@ -12,6 +12,7 @@ module ScreenshotScout
|
|
|
12
12
|
|
|
13
13
|
module CaptureFormat
|
|
14
14
|
GIF: String
|
|
15
|
+
HTML: String
|
|
15
16
|
JPEG: String
|
|
16
17
|
JPG: String
|
|
17
18
|
MD: String
|
|
@@ -248,13 +249,15 @@ module ScreenshotScout
|
|
|
248
249
|
attr_reader screenshot_url_expires_at: String?
|
|
249
250
|
attr_reader cache_status: String?
|
|
250
251
|
attr_reader markdown: String?
|
|
252
|
+
attr_reader html: String?
|
|
251
253
|
|
|
252
254
|
def initialize: (
|
|
253
255
|
raw_response: RawResponse,
|
|
254
256
|
screenshot_url: String?,
|
|
255
257
|
screenshot_url_expires_at: String?,
|
|
256
258
|
cache_status: String?,
|
|
257
|
-
?markdown: String
|
|
259
|
+
?markdown: String?,
|
|
260
|
+
?html: String?
|
|
258
261
|
) -> void
|
|
259
262
|
end
|
|
260
263
|
|