zyte-client 1.0.3 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zyte-client.rb +36 -19
- data/zyte-client.gemspec +3 -3
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f630a5f4d853e6754b2c95d2c196a53f3b44b7632bfacdfd64aab0c3b69fa17
|
4
|
+
data.tar.gz: a602c13529fc89e2fc6dd09a210264c27794e84d2e5ae042a0bf7693eb244d55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20d49f1fbb79a627f785524d51112103df7d83089f6082d5bf5e4ff08887d16e8e091b68c84b66caab7c99780632ca8d75ee655578d86ec9c7bd2a145c609db3
|
7
|
+
data.tar.gz: d0906d565585aac927ff2518be4568fa6b11b90c0c391ff610f3c49c42af16b2c2d01387765b8f16c02c8af42d6c95465341201fe609d195e431e929779b7937
|
data/lib/zyte-client.rb
CHANGED
@@ -12,25 +12,42 @@ class ZyteClient
|
|
12
12
|
self.key = h[:key] # mandatory
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
15
|
+
# call Zyte API's extract access point.
|
16
|
+
#
|
17
|
+
# url: the URL to extract.
|
18
|
+
# options: additonal Zyte API's options to the default request. Default request is: {"url": url}.
|
19
|
+
# json_parsing: if true, the response is parsed as JSON using jq command, and return the value of the `httpResponseBody` key. Default is true.
|
20
|
+
#
|
21
|
+
def extract(url:, json_parsing: true, options:{})
|
22
|
+
data = {
|
23
|
+
"url": url,
|
24
|
+
}.merge(options)
|
25
|
+
|
26
|
+
File.open('zyte.data.json', 'w') { |file| file.write(data.to_json) }
|
27
|
+
|
28
|
+
if json_parsing
|
29
|
+
cmd = "curl \
|
30
|
+
--silent \
|
31
|
+
--user #{self.key}: \
|
32
|
+
--header 'Content-Type: application/json' \
|
33
|
+
--data @zyte.data.json \
|
34
|
+
--compressed \
|
35
|
+
https://api.zyte.com/v1/extract \
|
36
|
+
| jq --raw-output .httpResponseBody \
|
37
|
+
| base64 --decode
|
38
|
+
"
|
39
|
+
else
|
40
|
+
cmd = "curl \
|
41
|
+
--silent \
|
42
|
+
--user #{self.key}: \
|
43
|
+
--header 'Content-Type: application/json' \
|
44
|
+
--data @zyte.data.json \
|
45
|
+
--compressed \
|
46
|
+
https://api.zyte.com/v1/extract
|
47
|
+
"
|
48
|
+
end
|
49
|
+
|
50
|
+
ret = `#{cmd}`
|
34
51
|
|
35
52
|
return ret
|
36
53
|
end # def zyte
|
data/zyte-client.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'zyte-client'
|
3
|
-
s.version = '1.0.
|
4
|
-
s.date = '
|
3
|
+
s.version = '1.0.5'
|
4
|
+
s.date = '2024-04-22'
|
5
5
|
s.summary = "Ruby library for operating Zyte API."
|
6
6
|
s.description = "Ruby library for operating Zyte API."
|
7
7
|
s.authors = ["Leandro Daniel Sardi"]
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
]
|
13
13
|
s.homepage = 'https://github.com/leandrosardi/zyte-client'
|
14
14
|
s.license = 'MIT'
|
15
|
-
s.add_runtime_dependency 'uri', '~> 0.
|
15
|
+
s.add_runtime_dependency 'uri', '~> 0.11.2', '>= 0.11.2'
|
16
16
|
s.add_runtime_dependency 'net-http', '~> 0.2.0', '>= 0.2.0'
|
17
17
|
s.add_runtime_dependency 'json', '~> 2.6.3', '>= 2.6.3'
|
18
18
|
s.add_runtime_dependency 'blackstack-core', '~> 1.2.15', '>= 1.2.15'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zyte-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uri
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.11.2
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 0.11.2
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.11.2
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
32
|
+
version: 0.11.2
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: net-http
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|