zyte-client 1.0.4 → 1.0.6
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 +4 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bffa19880c23434b27835026c2a7c517582c1307f7fde465262ea6f205c68658
|
4
|
+
data.tar.gz: 11e38f8ed341f9737d8815ec741b21f4de47fce821d19121c4b94eb4fdfc9f75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39e31548820edf9cdadcdf8d878009995ff2ff25d1a8b2618f303e0c122de36d0386d25da11beb0936553b260ca4980d9ce63579d4183ae77613f140ad173719
|
7
|
+
data.tar.gz: 2c05076f43fdc285c65aeee49364a81891c682a4a81b47f79d15b7b97244b4d7a6c6eacabd37640f0673c7ab22a9e7dd8fa29f4a116add51ef7af4e8e7b8336c
|
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:{}, data_filename: 'zyte.data.json')
|
22
|
+
data = {
|
23
|
+
"url": url,
|
24
|
+
}.merge(options)
|
25
|
+
|
26
|
+
File.open(data_filename, '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 @#{data_filename} \
|
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 @#{data_filename} \
|
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,16 +1,16 @@
|
|
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.6'
|
4
|
+
s.date = '2024-07-23'
|
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"]
|
8
|
-
s.email = 'leandro@
|
8
|
+
s.email = 'leandro@massprospecting.com'
|
9
9
|
s.files = [
|
10
10
|
'lib/zyte-client.rb',
|
11
11
|
'zyte-client.gemspec'
|
12
12
|
]
|
13
|
-
s.homepage = 'https://github.com/
|
13
|
+
s.homepage = 'https://github.com/massprospecting/zyte-client'
|
14
14
|
s.license = 'MIT'
|
15
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'
|
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.6
|
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-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uri
|
@@ -151,14 +151,14 @@ dependencies:
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 1.2.2
|
153
153
|
description: Ruby library for operating Zyte API.
|
154
|
-
email: leandro@
|
154
|
+
email: leandro@massprospecting.com
|
155
155
|
executables: []
|
156
156
|
extensions: []
|
157
157
|
extra_rdoc_files: []
|
158
158
|
files:
|
159
159
|
- lib/zyte-client.rb
|
160
160
|
- zyte-client.gemspec
|
161
|
-
homepage: https://github.com/
|
161
|
+
homepage: https://github.com/massprospecting/zyte-client
|
162
162
|
licenses:
|
163
163
|
- MIT
|
164
164
|
metadata: {}
|