webscraping_ai 1.0.0 → 2.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 +4 -4
- data/Gemfile +1 -1
- data/README.md +58 -21
- data/docs/Error.md +17 -0
- data/docs/HTMLApi.md +136 -0
- data/docs/PageError.md +19 -0
- data/docs/SelectedHTMLApi.md +274 -0
- data/lib/webscraping_ai.rb +7 -5
- data/lib/webscraping_ai/api/html_api.rb +133 -35
- data/lib/webscraping_ai/api/selected_html_api.rb +382 -0
- data/lib/webscraping_ai/api_client.rb +11 -9
- data/lib/webscraping_ai/api_error.rb +4 -4
- data/lib/webscraping_ai/configuration.rb +7 -7
- data/lib/webscraping_ai/models/error.rb +207 -0
- data/lib/webscraping_ai/models/{scrapped_page.rb → page_error.rb} +16 -36
- data/lib/webscraping_ai/version.rb +5 -5
- data/spec/api/html_api_spec.rb +36 -15
- data/spec/api/selected_html_api_spec.rb +103 -0
- data/spec/api_client_spec.rb +5 -5
- data/spec/configuration_spec.rb +7 -7
- data/spec/models/error_spec.rb +41 -0
- data/spec/models/page_error_spec.rb +47 -0
- data/spec/spec_helper.rb +4 -4
- data/webscraping_ai.gemspec +5 -5
- metadata +30 -23
- data/Gemfile.lock +0 -70
- data/docs/HtmlApi.md +0 -73
- data/docs/ScrappedPage.md +0 -23
- data/spec/models/scrapped_page_spec.rb +0 -59
data/lib/webscraping_ai.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
=begin
|
2
2
|
#WebScraping.AI
|
3
3
|
|
4
|
-
#A client for https://webscraping.ai API. It provides Chrome JS rendering, rotating proxies and HTML parsing
|
5
|
-
|
6
|
-
The version of the OpenAPI document: 1.0.0
|
4
|
+
#A client for https://webscraping.ai API. It provides a web scaping automation API with Chrome JS rendering, rotating proxies and builtin HTML parsing.
|
7
5
|
|
6
|
+
The version of the OpenAPI document: 2.0.0
|
7
|
+
Contact: support@webscraping.ai
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 4.
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -17,10 +17,12 @@ require 'webscraping_ai/version'
|
|
17
17
|
require 'webscraping_ai/configuration'
|
18
18
|
|
19
19
|
# Models
|
20
|
-
require 'webscraping_ai/models/
|
20
|
+
require 'webscraping_ai/models/error'
|
21
|
+
require 'webscraping_ai/models/page_error'
|
21
22
|
|
22
23
|
# APIs
|
23
24
|
require 'webscraping_ai/api/html_api'
|
25
|
+
require 'webscraping_ai/api/selected_html_api'
|
24
26
|
|
25
27
|
module WebScrapingAI
|
26
28
|
class << self
|
@@ -1,71 +1,82 @@
|
|
1
1
|
=begin
|
2
2
|
#WebScraping.AI
|
3
3
|
|
4
|
-
#A client for https://webscraping.ai API. It provides Chrome JS rendering, rotating proxies and HTML parsing
|
5
|
-
|
6
|
-
The version of the OpenAPI document: 1.0.0
|
4
|
+
#A client for https://webscraping.ai API. It provides a web scaping automation API with Chrome JS rendering, rotating proxies and builtin HTML parsing.
|
7
5
|
|
6
|
+
The version of the OpenAPI document: 2.0.0
|
7
|
+
Contact: support@webscraping.ai
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 4.
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
require 'cgi'
|
14
14
|
|
15
15
|
module WebScrapingAI
|
16
|
-
class
|
16
|
+
class HTMLApi
|
17
17
|
attr_accessor :api_client
|
18
18
|
|
19
19
|
def initialize(api_client = ApiClient.default)
|
20
20
|
@api_client = api_client
|
21
21
|
end
|
22
|
-
#
|
23
|
-
#
|
22
|
+
# Page HTML by URL
|
23
|
+
# Returns just HTML on success, JSON on error
|
24
|
+
# @param url [String] URL of the target page
|
24
25
|
# @param [Hash] opts the optional parameters
|
25
|
-
# @option opts [String] :
|
26
|
-
# @option opts [
|
27
|
-
# @option opts [
|
28
|
-
# @option opts [
|
29
|
-
# @
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
data
|
26
|
+
# @option opts [Hash<String, String>] :headers HTTP headers to pass to the target page. Can be specified either via a nested query parameter (...&headers[One]=value1&headers=[Another]=value2) or as a JSON encoded object (...&headers={\"One\": \"value1\", \"Another\": \"value2\"})
|
27
|
+
# @option opts [Integer] :timeout Maximum processing time in ms. Increase it in case of timeout errors (5000 by default, maximum is 30000) (default to 5000)
|
28
|
+
# @option opts [Boolean] :js Execute on-page JavaScript using a headless browser (true by default), costs 2 requests (default to true)
|
29
|
+
# @option opts [String] :proxy Type of proxy, use residential proxies if your site restricts traffic from datacenters (datacenter by default) (default to 'datacenter')
|
30
|
+
# @return [nil]
|
31
|
+
def get_html(url, opts = {})
|
32
|
+
get_html_with_http_info(url, opts)
|
33
|
+
nil
|
34
34
|
end
|
35
35
|
|
36
|
-
#
|
37
|
-
#
|
36
|
+
# Page HTML by URL
|
37
|
+
# Returns just HTML on success, JSON on error
|
38
|
+
# @param url [String] URL of the target page
|
38
39
|
# @param [Hash] opts the optional parameters
|
39
|
-
# @option opts [String] :
|
40
|
-
# @option opts [
|
41
|
-
# @option opts [
|
42
|
-
# @option opts [
|
43
|
-
# @
|
44
|
-
|
45
|
-
def get_page_with_http_info(url, opts = {})
|
40
|
+
# @option opts [Hash<String, String>] :headers HTTP headers to pass to the target page. Can be specified either via a nested query parameter (...&headers[One]=value1&headers=[Another]=value2) or as a JSON encoded object (...&headers={\"One\": \"value1\", \"Another\": \"value2\"})
|
41
|
+
# @option opts [Integer] :timeout Maximum processing time in ms. Increase it in case of timeout errors (5000 by default, maximum is 30000)
|
42
|
+
# @option opts [Boolean] :js Execute on-page JavaScript using a headless browser (true by default), costs 2 requests
|
43
|
+
# @option opts [String] :proxy Type of proxy, use residential proxies if your site restricts traffic from datacenters (datacenter by default)
|
44
|
+
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
|
45
|
+
def get_html_with_http_info(url, opts = {})
|
46
46
|
if @api_client.config.debugging
|
47
|
-
@api_client.config.logger.debug 'Calling API:
|
47
|
+
@api_client.config.logger.debug 'Calling API: HTMLApi.get_html ...'
|
48
48
|
end
|
49
49
|
# verify the required parameter 'url' is set
|
50
50
|
if @api_client.config.client_side_validation && url.nil?
|
51
|
-
fail ArgumentError, "Missing the required parameter 'url' when calling
|
51
|
+
fail ArgumentError, "Missing the required parameter 'url' when calling HTMLApi.get_html"
|
52
|
+
end
|
53
|
+
if @api_client.config.client_side_validation && !opts[:'timeout'].nil? && opts[:'timeout'] > 30000
|
54
|
+
fail ArgumentError, 'invalid value for "opts[:"timeout"]" when calling HTMLApi.get_html, must be smaller than or equal to 30000.'
|
55
|
+
end
|
56
|
+
|
57
|
+
if @api_client.config.client_side_validation && !opts[:'timeout'].nil? && opts[:'timeout'] < 1
|
58
|
+
fail ArgumentError, 'invalid value for "opts[:"timeout"]" when calling HTMLApi.get_html, must be greater than or equal to 1.'
|
59
|
+
end
|
60
|
+
|
61
|
+
allowable_values = ["datacenter", "residential"]
|
62
|
+
if @api_client.config.client_side_validation && opts[:'proxy'] && !allowable_values.include?(opts[:'proxy'])
|
63
|
+
fail ArgumentError, "invalid value for \"proxy\", must be one of #{allowable_values}"
|
52
64
|
end
|
53
65
|
# resource path
|
54
|
-
local_var_path = '/'
|
66
|
+
local_var_path = '/html'
|
55
67
|
|
56
68
|
# query parameters
|
57
69
|
query_params = opts[:query_params] || {}
|
58
70
|
query_params[:'url'] = url
|
59
|
-
query_params[:'
|
60
|
-
query_params[:'
|
71
|
+
query_params[:'headers'] = opts[:'headers'] if !opts[:'headers'].nil?
|
72
|
+
query_params[:'timeout'] = opts[:'timeout'] if !opts[:'timeout'].nil?
|
73
|
+
query_params[:'js'] = opts[:'js'] if !opts[:'js'].nil?
|
61
74
|
query_params[:'proxy'] = opts[:'proxy'] if !opts[:'proxy'].nil?
|
62
|
-
query_params[:'disable_js'] = opts[:'disable_js'] if !opts[:'disable_js'].nil?
|
63
|
-
query_params[:'inline_css'] = opts[:'inline_css'] if !opts[:'inline_css'].nil?
|
64
75
|
|
65
76
|
# header parameters
|
66
77
|
header_params = opts[:header_params] || {}
|
67
78
|
# HTTP header 'Accept' (if needed)
|
68
|
-
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
79
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/html'])
|
69
80
|
|
70
81
|
# form parameters
|
71
82
|
form_params = opts[:form_params] || {}
|
@@ -74,7 +85,7 @@ module WebScrapingAI
|
|
74
85
|
post_body = opts[:body]
|
75
86
|
|
76
87
|
# return_type
|
77
|
-
return_type = opts[:return_type]
|
88
|
+
return_type = opts[:return_type]
|
78
89
|
|
79
90
|
# auth_names
|
80
91
|
auth_names = opts[:auth_names] || ['api_key']
|
@@ -90,7 +101,94 @@ module WebScrapingAI
|
|
90
101
|
|
91
102
|
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
92
103
|
if @api_client.config.debugging
|
93
|
-
@api_client.config.logger.debug "API called:
|
104
|
+
@api_client.config.logger.debug "API called: HTMLApi#get_html\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
105
|
+
end
|
106
|
+
return data, status_code, headers
|
107
|
+
end
|
108
|
+
|
109
|
+
# Page HTML by URL with POST request to the target page
|
110
|
+
# Returns just HTML on success, JSON on error. Request body will be passed to the target page.
|
111
|
+
# @param url [String] URL of the target page
|
112
|
+
# @param [Hash] opts the optional parameters
|
113
|
+
# @option opts [Hash<String, String>] :headers HTTP headers to pass to the target page. Can be specified either via a nested query parameter (...&headers[One]=value1&headers=[Another]=value2) or as a JSON encoded object (...&headers={\"One\": \"value1\", \"Another\": \"value2\"})
|
114
|
+
# @option opts [Integer] :timeout Maximum processing time in ms. Increase it in case of timeout errors (5000 by default, maximum is 30000) (default to 5000)
|
115
|
+
# @option opts [Boolean] :js Execute on-page JavaScript using a headless browser (true by default), costs 2 requests (default to true)
|
116
|
+
# @option opts [String] :proxy Type of proxy, use residential proxies if your site restricts traffic from datacenters (datacenter by default) (default to 'datacenter')
|
117
|
+
# @return [nil]
|
118
|
+
def post_html(url, opts = {})
|
119
|
+
post_html_with_http_info(url, opts)
|
120
|
+
nil
|
121
|
+
end
|
122
|
+
|
123
|
+
# Page HTML by URL with POST request to the target page
|
124
|
+
# Returns just HTML on success, JSON on error. Request body will be passed to the target page.
|
125
|
+
# @param url [String] URL of the target page
|
126
|
+
# @param [Hash] opts the optional parameters
|
127
|
+
# @option opts [Hash<String, String>] :headers HTTP headers to pass to the target page. Can be specified either via a nested query parameter (...&headers[One]=value1&headers=[Another]=value2) or as a JSON encoded object (...&headers={\"One\": \"value1\", \"Another\": \"value2\"})
|
128
|
+
# @option opts [Integer] :timeout Maximum processing time in ms. Increase it in case of timeout errors (5000 by default, maximum is 30000)
|
129
|
+
# @option opts [Boolean] :js Execute on-page JavaScript using a headless browser (true by default), costs 2 requests
|
130
|
+
# @option opts [String] :proxy Type of proxy, use residential proxies if your site restricts traffic from datacenters (datacenter by default)
|
131
|
+
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
|
132
|
+
def post_html_with_http_info(url, opts = {})
|
133
|
+
if @api_client.config.debugging
|
134
|
+
@api_client.config.logger.debug 'Calling API: HTMLApi.post_html ...'
|
135
|
+
end
|
136
|
+
# verify the required parameter 'url' is set
|
137
|
+
if @api_client.config.client_side_validation && url.nil?
|
138
|
+
fail ArgumentError, "Missing the required parameter 'url' when calling HTMLApi.post_html"
|
139
|
+
end
|
140
|
+
if @api_client.config.client_side_validation && !opts[:'timeout'].nil? && opts[:'timeout'] > 30000
|
141
|
+
fail ArgumentError, 'invalid value for "opts[:"timeout"]" when calling HTMLApi.post_html, must be smaller than or equal to 30000.'
|
142
|
+
end
|
143
|
+
|
144
|
+
if @api_client.config.client_side_validation && !opts[:'timeout'].nil? && opts[:'timeout'] < 1
|
145
|
+
fail ArgumentError, 'invalid value for "opts[:"timeout"]" when calling HTMLApi.post_html, must be greater than or equal to 1.'
|
146
|
+
end
|
147
|
+
|
148
|
+
allowable_values = ["datacenter", "residential"]
|
149
|
+
if @api_client.config.client_side_validation && opts[:'proxy'] && !allowable_values.include?(opts[:'proxy'])
|
150
|
+
fail ArgumentError, "invalid value for \"proxy\", must be one of #{allowable_values}"
|
151
|
+
end
|
152
|
+
# resource path
|
153
|
+
local_var_path = '/html'
|
154
|
+
|
155
|
+
# query parameters
|
156
|
+
query_params = opts[:query_params] || {}
|
157
|
+
query_params[:'url'] = url
|
158
|
+
query_params[:'headers'] = opts[:'headers'] if !opts[:'headers'].nil?
|
159
|
+
query_params[:'timeout'] = opts[:'timeout'] if !opts[:'timeout'].nil?
|
160
|
+
query_params[:'js'] = opts[:'js'] if !opts[:'js'].nil?
|
161
|
+
query_params[:'proxy'] = opts[:'proxy'] if !opts[:'proxy'].nil?
|
162
|
+
|
163
|
+
# header parameters
|
164
|
+
header_params = opts[:header_params] || {}
|
165
|
+
# HTTP header 'Accept' (if needed)
|
166
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/html'])
|
167
|
+
|
168
|
+
# form parameters
|
169
|
+
form_params = opts[:form_params] || {}
|
170
|
+
|
171
|
+
# http body (model)
|
172
|
+
post_body = opts[:body]
|
173
|
+
|
174
|
+
# return_type
|
175
|
+
return_type = opts[:return_type]
|
176
|
+
|
177
|
+
# auth_names
|
178
|
+
auth_names = opts[:auth_names] || ['api_key']
|
179
|
+
|
180
|
+
new_options = opts.merge(
|
181
|
+
:header_params => header_params,
|
182
|
+
:query_params => query_params,
|
183
|
+
:form_params => form_params,
|
184
|
+
:body => post_body,
|
185
|
+
:auth_names => auth_names,
|
186
|
+
:return_type => return_type
|
187
|
+
)
|
188
|
+
|
189
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
190
|
+
if @api_client.config.debugging
|
191
|
+
@api_client.config.logger.debug "API called: HTMLApi#post_html\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
94
192
|
end
|
95
193
|
return data, status_code, headers
|
96
194
|
end
|
@@ -0,0 +1,382 @@
|
|
1
|
+
=begin
|
2
|
+
#WebScraping.AI
|
3
|
+
|
4
|
+
#A client for https://webscraping.ai API. It provides a web scaping automation API with Chrome JS rendering, rotating proxies and builtin HTML parsing.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2.0.0
|
7
|
+
Contact: support@webscraping.ai
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'cgi'
|
14
|
+
|
15
|
+
module WebScrapingAI
|
16
|
+
class SelectedHTMLApi
|
17
|
+
attr_accessor :api_client
|
18
|
+
|
19
|
+
def initialize(api_client = ApiClient.default)
|
20
|
+
@api_client = api_client
|
21
|
+
end
|
22
|
+
# HTML of a selected page area by URL and CSS selector
|
23
|
+
# Returns just HTML on success, JSON on error
|
24
|
+
# @param url [String] URL of the target page
|
25
|
+
# @param [Hash] opts the optional parameters
|
26
|
+
# @option opts [String] :selector CSS selector (null by default, returns whole page HTML)
|
27
|
+
# @option opts [Hash<String, String>] :headers HTTP headers to pass to the target page. Can be specified either via a nested query parameter (...&headers[One]=value1&headers=[Another]=value2) or as a JSON encoded object (...&headers={\"One\": \"value1\", \"Another\": \"value2\"})
|
28
|
+
# @option opts [Integer] :timeout Maximum processing time in ms. Increase it in case of timeout errors (5000 by default, maximum is 30000) (default to 5000)
|
29
|
+
# @option opts [Boolean] :js Execute on-page JavaScript using a headless browser (true by default), costs 2 requests (default to true)
|
30
|
+
# @option opts [String] :proxy Type of proxy, use residential proxies if your site restricts traffic from datacenters (datacenter by default) (default to 'datacenter')
|
31
|
+
# @return [nil]
|
32
|
+
def get_selected(url, opts = {})
|
33
|
+
get_selected_with_http_info(url, opts)
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
|
37
|
+
# HTML of a selected page area by URL and CSS selector
|
38
|
+
# Returns just HTML on success, JSON on error
|
39
|
+
# @param url [String] URL of the target page
|
40
|
+
# @param [Hash] opts the optional parameters
|
41
|
+
# @option opts [String] :selector CSS selector (null by default, returns whole page HTML)
|
42
|
+
# @option opts [Hash<String, String>] :headers HTTP headers to pass to the target page. Can be specified either via a nested query parameter (...&headers[One]=value1&headers=[Another]=value2) or as a JSON encoded object (...&headers={\"One\": \"value1\", \"Another\": \"value2\"})
|
43
|
+
# @option opts [Integer] :timeout Maximum processing time in ms. Increase it in case of timeout errors (5000 by default, maximum is 30000)
|
44
|
+
# @option opts [Boolean] :js Execute on-page JavaScript using a headless browser (true by default), costs 2 requests
|
45
|
+
# @option opts [String] :proxy Type of proxy, use residential proxies if your site restricts traffic from datacenters (datacenter by default)
|
46
|
+
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
|
47
|
+
def get_selected_with_http_info(url, opts = {})
|
48
|
+
if @api_client.config.debugging
|
49
|
+
@api_client.config.logger.debug 'Calling API: SelectedHTMLApi.get_selected ...'
|
50
|
+
end
|
51
|
+
# verify the required parameter 'url' is set
|
52
|
+
if @api_client.config.client_side_validation && url.nil?
|
53
|
+
fail ArgumentError, "Missing the required parameter 'url' when calling SelectedHTMLApi.get_selected"
|
54
|
+
end
|
55
|
+
if @api_client.config.client_side_validation && !opts[:'timeout'].nil? && opts[:'timeout'] > 30000
|
56
|
+
fail ArgumentError, 'invalid value for "opts[:"timeout"]" when calling SelectedHTMLApi.get_selected, must be smaller than or equal to 30000.'
|
57
|
+
end
|
58
|
+
|
59
|
+
if @api_client.config.client_side_validation && !opts[:'timeout'].nil? && opts[:'timeout'] < 1
|
60
|
+
fail ArgumentError, 'invalid value for "opts[:"timeout"]" when calling SelectedHTMLApi.get_selected, must be greater than or equal to 1.'
|
61
|
+
end
|
62
|
+
|
63
|
+
allowable_values = ["datacenter", "residential"]
|
64
|
+
if @api_client.config.client_side_validation && opts[:'proxy'] && !allowable_values.include?(opts[:'proxy'])
|
65
|
+
fail ArgumentError, "invalid value for \"proxy\", must be one of #{allowable_values}"
|
66
|
+
end
|
67
|
+
# resource path
|
68
|
+
local_var_path = '/selected'
|
69
|
+
|
70
|
+
# query parameters
|
71
|
+
query_params = opts[:query_params] || {}
|
72
|
+
query_params[:'url'] = url
|
73
|
+
query_params[:'selector'] = opts[:'selector'] if !opts[:'selector'].nil?
|
74
|
+
query_params[:'headers'] = opts[:'headers'] if !opts[:'headers'].nil?
|
75
|
+
query_params[:'timeout'] = opts[:'timeout'] if !opts[:'timeout'].nil?
|
76
|
+
query_params[:'js'] = opts[:'js'] if !opts[:'js'].nil?
|
77
|
+
query_params[:'proxy'] = opts[:'proxy'] if !opts[:'proxy'].nil?
|
78
|
+
|
79
|
+
# header parameters
|
80
|
+
header_params = opts[:header_params] || {}
|
81
|
+
# HTTP header 'Accept' (if needed)
|
82
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/html'])
|
83
|
+
|
84
|
+
# form parameters
|
85
|
+
form_params = opts[:form_params] || {}
|
86
|
+
|
87
|
+
# http body (model)
|
88
|
+
post_body = opts[:body]
|
89
|
+
|
90
|
+
# return_type
|
91
|
+
return_type = opts[:return_type]
|
92
|
+
|
93
|
+
# auth_names
|
94
|
+
auth_names = opts[:auth_names] || ['api_key']
|
95
|
+
|
96
|
+
new_options = opts.merge(
|
97
|
+
:header_params => header_params,
|
98
|
+
:query_params => query_params,
|
99
|
+
:form_params => form_params,
|
100
|
+
:body => post_body,
|
101
|
+
:auth_names => auth_names,
|
102
|
+
:return_type => return_type
|
103
|
+
)
|
104
|
+
|
105
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
106
|
+
if @api_client.config.debugging
|
107
|
+
@api_client.config.logger.debug "API called: SelectedHTMLApi#get_selected\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
108
|
+
end
|
109
|
+
return data, status_code, headers
|
110
|
+
end
|
111
|
+
|
112
|
+
# HTML of multiple page areas by URL and CSS selectors
|
113
|
+
# Always returns JSON
|
114
|
+
# @param url [String] URL of the target page
|
115
|
+
# @param [Hash] opts the optional parameters
|
116
|
+
# @option opts [Array<String>] :selectors Multiple CSS selectors (null by default, returns whole page HTML)
|
117
|
+
# @option opts [Hash<String, String>] :headers HTTP headers to pass to the target page. Can be specified either via a nested query parameter (...&headers[One]=value1&headers=[Another]=value2) or as a JSON encoded object (...&headers={\"One\": \"value1\", \"Another\": \"value2\"})
|
118
|
+
# @option opts [Integer] :timeout Maximum processing time in ms. Increase it in case of timeout errors (5000 by default, maximum is 30000) (default to 5000)
|
119
|
+
# @option opts [Boolean] :js Execute on-page JavaScript using a headless browser (true by default), costs 2 requests (default to true)
|
120
|
+
# @option opts [String] :proxy Type of proxy, use residential proxies if your site restricts traffic from datacenters (datacenter by default) (default to 'datacenter')
|
121
|
+
# @return [Array<String>]
|
122
|
+
def get_selected_multiple(url, opts = {})
|
123
|
+
data, _status_code, _headers = get_selected_multiple_with_http_info(url, opts)
|
124
|
+
data
|
125
|
+
end
|
126
|
+
|
127
|
+
# HTML of multiple page areas by URL and CSS selectors
|
128
|
+
# Always returns JSON
|
129
|
+
# @param url [String] URL of the target page
|
130
|
+
# @param [Hash] opts the optional parameters
|
131
|
+
# @option opts [Array<String>] :selectors Multiple CSS selectors (null by default, returns whole page HTML)
|
132
|
+
# @option opts [Hash<String, String>] :headers HTTP headers to pass to the target page. Can be specified either via a nested query parameter (...&headers[One]=value1&headers=[Another]=value2) or as a JSON encoded object (...&headers={\"One\": \"value1\", \"Another\": \"value2\"})
|
133
|
+
# @option opts [Integer] :timeout Maximum processing time in ms. Increase it in case of timeout errors (5000 by default, maximum is 30000)
|
134
|
+
# @option opts [Boolean] :js Execute on-page JavaScript using a headless browser (true by default), costs 2 requests
|
135
|
+
# @option opts [String] :proxy Type of proxy, use residential proxies if your site restricts traffic from datacenters (datacenter by default)
|
136
|
+
# @return [Array<(Array<String>, Integer, Hash)>] Array<String> data, response status code and response headers
|
137
|
+
def get_selected_multiple_with_http_info(url, opts = {})
|
138
|
+
if @api_client.config.debugging
|
139
|
+
@api_client.config.logger.debug 'Calling API: SelectedHTMLApi.get_selected_multiple ...'
|
140
|
+
end
|
141
|
+
# verify the required parameter 'url' is set
|
142
|
+
if @api_client.config.client_side_validation && url.nil?
|
143
|
+
fail ArgumentError, "Missing the required parameter 'url' when calling SelectedHTMLApi.get_selected_multiple"
|
144
|
+
end
|
145
|
+
if @api_client.config.client_side_validation && !opts[:'timeout'].nil? && opts[:'timeout'] > 30000
|
146
|
+
fail ArgumentError, 'invalid value for "opts[:"timeout"]" when calling SelectedHTMLApi.get_selected_multiple, must be smaller than or equal to 30000.'
|
147
|
+
end
|
148
|
+
|
149
|
+
if @api_client.config.client_side_validation && !opts[:'timeout'].nil? && opts[:'timeout'] < 1
|
150
|
+
fail ArgumentError, 'invalid value for "opts[:"timeout"]" when calling SelectedHTMLApi.get_selected_multiple, must be greater than or equal to 1.'
|
151
|
+
end
|
152
|
+
|
153
|
+
allowable_values = ["datacenter", "residential"]
|
154
|
+
if @api_client.config.client_side_validation && opts[:'proxy'] && !allowable_values.include?(opts[:'proxy'])
|
155
|
+
fail ArgumentError, "invalid value for \"proxy\", must be one of #{allowable_values}"
|
156
|
+
end
|
157
|
+
# resource path
|
158
|
+
local_var_path = '/selected-multiple'
|
159
|
+
|
160
|
+
# query parameters
|
161
|
+
query_params = opts[:query_params] || {}
|
162
|
+
query_params[:'url'] = url
|
163
|
+
query_params[:'selectors'] = @api_client.build_collection_param(opts[:'selectors'], :multi) if !opts[:'selectors'].nil?
|
164
|
+
query_params[:'headers'] = opts[:'headers'] if !opts[:'headers'].nil?
|
165
|
+
query_params[:'timeout'] = opts[:'timeout'] if !opts[:'timeout'].nil?
|
166
|
+
query_params[:'js'] = opts[:'js'] if !opts[:'js'].nil?
|
167
|
+
query_params[:'proxy'] = opts[:'proxy'] if !opts[:'proxy'].nil?
|
168
|
+
|
169
|
+
# header parameters
|
170
|
+
header_params = opts[:header_params] || {}
|
171
|
+
# HTTP header 'Accept' (if needed)
|
172
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
173
|
+
|
174
|
+
# form parameters
|
175
|
+
form_params = opts[:form_params] || {}
|
176
|
+
|
177
|
+
# http body (model)
|
178
|
+
post_body = opts[:body]
|
179
|
+
|
180
|
+
# return_type
|
181
|
+
return_type = opts[:return_type] || 'Array<String>'
|
182
|
+
|
183
|
+
# auth_names
|
184
|
+
auth_names = opts[:auth_names] || ['api_key']
|
185
|
+
|
186
|
+
new_options = opts.merge(
|
187
|
+
:header_params => header_params,
|
188
|
+
:query_params => query_params,
|
189
|
+
:form_params => form_params,
|
190
|
+
:body => post_body,
|
191
|
+
:auth_names => auth_names,
|
192
|
+
:return_type => return_type
|
193
|
+
)
|
194
|
+
|
195
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
196
|
+
if @api_client.config.debugging
|
197
|
+
@api_client.config.logger.debug "API called: SelectedHTMLApi#get_selected_multiple\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
198
|
+
end
|
199
|
+
return data, status_code, headers
|
200
|
+
end
|
201
|
+
|
202
|
+
# HTML of a selected page areas by URL and CSS selector, with POST request to the target page
|
203
|
+
# Returns just HTML on success, JSON on error. Request body will be passed to the target page.
|
204
|
+
# @param url [String] URL of the target page
|
205
|
+
# @param [Hash] opts the optional parameters
|
206
|
+
# @option opts [String] :selector CSS selector (null by default, returns whole page HTML)
|
207
|
+
# @option opts [Hash<String, String>] :headers HTTP headers to pass to the target page. Can be specified either via a nested query parameter (...&headers[One]=value1&headers=[Another]=value2) or as a JSON encoded object (...&headers={\"One\": \"value1\", \"Another\": \"value2\"})
|
208
|
+
# @option opts [Integer] :timeout Maximum processing time in ms. Increase it in case of timeout errors (5000 by default, maximum is 30000) (default to 5000)
|
209
|
+
# @option opts [Boolean] :js Execute on-page JavaScript using a headless browser (true by default), costs 2 requests (default to true)
|
210
|
+
# @option opts [String] :proxy Type of proxy, use residential proxies if your site restricts traffic from datacenters (datacenter by default) (default to 'datacenter')
|
211
|
+
# @return [nil]
|
212
|
+
def post_selected(url, opts = {})
|
213
|
+
post_selected_with_http_info(url, opts)
|
214
|
+
nil
|
215
|
+
end
|
216
|
+
|
217
|
+
# HTML of a selected page areas by URL and CSS selector, with POST request to the target page
|
218
|
+
# Returns just HTML on success, JSON on error. Request body will be passed to the target page.
|
219
|
+
# @param url [String] URL of the target page
|
220
|
+
# @param [Hash] opts the optional parameters
|
221
|
+
# @option opts [String] :selector CSS selector (null by default, returns whole page HTML)
|
222
|
+
# @option opts [Hash<String, String>] :headers HTTP headers to pass to the target page. Can be specified either via a nested query parameter (...&headers[One]=value1&headers=[Another]=value2) or as a JSON encoded object (...&headers={\"One\": \"value1\", \"Another\": \"value2\"})
|
223
|
+
# @option opts [Integer] :timeout Maximum processing time in ms. Increase it in case of timeout errors (5000 by default, maximum is 30000)
|
224
|
+
# @option opts [Boolean] :js Execute on-page JavaScript using a headless browser (true by default), costs 2 requests
|
225
|
+
# @option opts [String] :proxy Type of proxy, use residential proxies if your site restricts traffic from datacenters (datacenter by default)
|
226
|
+
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
|
227
|
+
def post_selected_with_http_info(url, opts = {})
|
228
|
+
if @api_client.config.debugging
|
229
|
+
@api_client.config.logger.debug 'Calling API: SelectedHTMLApi.post_selected ...'
|
230
|
+
end
|
231
|
+
# verify the required parameter 'url' is set
|
232
|
+
if @api_client.config.client_side_validation && url.nil?
|
233
|
+
fail ArgumentError, "Missing the required parameter 'url' when calling SelectedHTMLApi.post_selected"
|
234
|
+
end
|
235
|
+
if @api_client.config.client_side_validation && !opts[:'timeout'].nil? && opts[:'timeout'] > 30000
|
236
|
+
fail ArgumentError, 'invalid value for "opts[:"timeout"]" when calling SelectedHTMLApi.post_selected, must be smaller than or equal to 30000.'
|
237
|
+
end
|
238
|
+
|
239
|
+
if @api_client.config.client_side_validation && !opts[:'timeout'].nil? && opts[:'timeout'] < 1
|
240
|
+
fail ArgumentError, 'invalid value for "opts[:"timeout"]" when calling SelectedHTMLApi.post_selected, must be greater than or equal to 1.'
|
241
|
+
end
|
242
|
+
|
243
|
+
allowable_values = ["datacenter", "residential"]
|
244
|
+
if @api_client.config.client_side_validation && opts[:'proxy'] && !allowable_values.include?(opts[:'proxy'])
|
245
|
+
fail ArgumentError, "invalid value for \"proxy\", must be one of #{allowable_values}"
|
246
|
+
end
|
247
|
+
# resource path
|
248
|
+
local_var_path = '/selected'
|
249
|
+
|
250
|
+
# query parameters
|
251
|
+
query_params = opts[:query_params] || {}
|
252
|
+
query_params[:'url'] = url
|
253
|
+
query_params[:'selector'] = opts[:'selector'] if !opts[:'selector'].nil?
|
254
|
+
query_params[:'headers'] = opts[:'headers'] if !opts[:'headers'].nil?
|
255
|
+
query_params[:'timeout'] = opts[:'timeout'] if !opts[:'timeout'].nil?
|
256
|
+
query_params[:'js'] = opts[:'js'] if !opts[:'js'].nil?
|
257
|
+
query_params[:'proxy'] = opts[:'proxy'] if !opts[:'proxy'].nil?
|
258
|
+
|
259
|
+
# header parameters
|
260
|
+
header_params = opts[:header_params] || {}
|
261
|
+
# HTTP header 'Accept' (if needed)
|
262
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/html'])
|
263
|
+
|
264
|
+
# form parameters
|
265
|
+
form_params = opts[:form_params] || {}
|
266
|
+
|
267
|
+
# http body (model)
|
268
|
+
post_body = opts[:body]
|
269
|
+
|
270
|
+
# return_type
|
271
|
+
return_type = opts[:return_type]
|
272
|
+
|
273
|
+
# auth_names
|
274
|
+
auth_names = opts[:auth_names] || ['api_key']
|
275
|
+
|
276
|
+
new_options = opts.merge(
|
277
|
+
:header_params => header_params,
|
278
|
+
:query_params => query_params,
|
279
|
+
:form_params => form_params,
|
280
|
+
:body => post_body,
|
281
|
+
:auth_names => auth_names,
|
282
|
+
:return_type => return_type
|
283
|
+
)
|
284
|
+
|
285
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
286
|
+
if @api_client.config.debugging
|
287
|
+
@api_client.config.logger.debug "API called: SelectedHTMLApi#post_selected\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
288
|
+
end
|
289
|
+
return data, status_code, headers
|
290
|
+
end
|
291
|
+
|
292
|
+
# HTML of multiple page areas by URL and CSS selectors, with POST request to the target page
|
293
|
+
# Always returns JSON. Request body will be passed to the target page.
|
294
|
+
# @param url [String] URL of the target page
|
295
|
+
# @param [Hash] opts the optional parameters
|
296
|
+
# @option opts [Array<String>] :selectors Multiple CSS selectors (null by default, returns whole page HTML)
|
297
|
+
# @option opts [Hash<String, String>] :headers HTTP headers to pass to the target page. Can be specified either via a nested query parameter (...&headers[One]=value1&headers=[Another]=value2) or as a JSON encoded object (...&headers={\"One\": \"value1\", \"Another\": \"value2\"})
|
298
|
+
# @option opts [Integer] :timeout Maximum processing time in ms. Increase it in case of timeout errors (5000 by default, maximum is 30000) (default to 5000)
|
299
|
+
# @option opts [Boolean] :js Execute on-page JavaScript using a headless browser (true by default), costs 2 requests (default to true)
|
300
|
+
# @option opts [String] :proxy Type of proxy, use residential proxies if your site restricts traffic from datacenters (datacenter by default) (default to 'datacenter')
|
301
|
+
# @return [Array<String>]
|
302
|
+
def post_selected_multiple(url, opts = {})
|
303
|
+
data, _status_code, _headers = post_selected_multiple_with_http_info(url, opts)
|
304
|
+
data
|
305
|
+
end
|
306
|
+
|
307
|
+
# HTML of multiple page areas by URL and CSS selectors, with POST request to the target page
|
308
|
+
# Always returns JSON. Request body will be passed to the target page.
|
309
|
+
# @param url [String] URL of the target page
|
310
|
+
# @param [Hash] opts the optional parameters
|
311
|
+
# @option opts [Array<String>] :selectors Multiple CSS selectors (null by default, returns whole page HTML)
|
312
|
+
# @option opts [Hash<String, String>] :headers HTTP headers to pass to the target page. Can be specified either via a nested query parameter (...&headers[One]=value1&headers=[Another]=value2) or as a JSON encoded object (...&headers={\"One\": \"value1\", \"Another\": \"value2\"})
|
313
|
+
# @option opts [Integer] :timeout Maximum processing time in ms. Increase it in case of timeout errors (5000 by default, maximum is 30000)
|
314
|
+
# @option opts [Boolean] :js Execute on-page JavaScript using a headless browser (true by default), costs 2 requests
|
315
|
+
# @option opts [String] :proxy Type of proxy, use residential proxies if your site restricts traffic from datacenters (datacenter by default)
|
316
|
+
# @return [Array<(Array<String>, Integer, Hash)>] Array<String> data, response status code and response headers
|
317
|
+
def post_selected_multiple_with_http_info(url, opts = {})
|
318
|
+
if @api_client.config.debugging
|
319
|
+
@api_client.config.logger.debug 'Calling API: SelectedHTMLApi.post_selected_multiple ...'
|
320
|
+
end
|
321
|
+
# verify the required parameter 'url' is set
|
322
|
+
if @api_client.config.client_side_validation && url.nil?
|
323
|
+
fail ArgumentError, "Missing the required parameter 'url' when calling SelectedHTMLApi.post_selected_multiple"
|
324
|
+
end
|
325
|
+
if @api_client.config.client_side_validation && !opts[:'timeout'].nil? && opts[:'timeout'] > 30000
|
326
|
+
fail ArgumentError, 'invalid value for "opts[:"timeout"]" when calling SelectedHTMLApi.post_selected_multiple, must be smaller than or equal to 30000.'
|
327
|
+
end
|
328
|
+
|
329
|
+
if @api_client.config.client_side_validation && !opts[:'timeout'].nil? && opts[:'timeout'] < 1
|
330
|
+
fail ArgumentError, 'invalid value for "opts[:"timeout"]" when calling SelectedHTMLApi.post_selected_multiple, must be greater than or equal to 1.'
|
331
|
+
end
|
332
|
+
|
333
|
+
allowable_values = ["datacenter", "residential"]
|
334
|
+
if @api_client.config.client_side_validation && opts[:'proxy'] && !allowable_values.include?(opts[:'proxy'])
|
335
|
+
fail ArgumentError, "invalid value for \"proxy\", must be one of #{allowable_values}"
|
336
|
+
end
|
337
|
+
# resource path
|
338
|
+
local_var_path = '/selected-multiple'
|
339
|
+
|
340
|
+
# query parameters
|
341
|
+
query_params = opts[:query_params] || {}
|
342
|
+
query_params[:'url'] = url
|
343
|
+
query_params[:'selectors'] = @api_client.build_collection_param(opts[:'selectors'], :multi) if !opts[:'selectors'].nil?
|
344
|
+
query_params[:'headers'] = opts[:'headers'] if !opts[:'headers'].nil?
|
345
|
+
query_params[:'timeout'] = opts[:'timeout'] if !opts[:'timeout'].nil?
|
346
|
+
query_params[:'js'] = opts[:'js'] if !opts[:'js'].nil?
|
347
|
+
query_params[:'proxy'] = opts[:'proxy'] if !opts[:'proxy'].nil?
|
348
|
+
|
349
|
+
# header parameters
|
350
|
+
header_params = opts[:header_params] || {}
|
351
|
+
# HTTP header 'Accept' (if needed)
|
352
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
353
|
+
|
354
|
+
# form parameters
|
355
|
+
form_params = opts[:form_params] || {}
|
356
|
+
|
357
|
+
# http body (model)
|
358
|
+
post_body = opts[:body]
|
359
|
+
|
360
|
+
# return_type
|
361
|
+
return_type = opts[:return_type] || 'Array<String>'
|
362
|
+
|
363
|
+
# auth_names
|
364
|
+
auth_names = opts[:auth_names] || ['api_key']
|
365
|
+
|
366
|
+
new_options = opts.merge(
|
367
|
+
:header_params => header_params,
|
368
|
+
:query_params => query_params,
|
369
|
+
:form_params => form_params,
|
370
|
+
:body => post_body,
|
371
|
+
:auth_names => auth_names,
|
372
|
+
:return_type => return_type
|
373
|
+
)
|
374
|
+
|
375
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
376
|
+
if @api_client.config.debugging
|
377
|
+
@api_client.config.logger.debug "API called: SelectedHTMLApi#post_selected_multiple\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
378
|
+
end
|
379
|
+
return data, status_code, headers
|
380
|
+
end
|
381
|
+
end
|
382
|
+
end
|