Skip to content

Commit bc97b49

Browse files
committed
docstring limits
1 parent 496f50e commit bc97b49

File tree

15 files changed

+555
-262
lines changed

15 files changed

+555
-262
lines changed

src/oxylabs/internal/internal.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def __init__(self, username: str, password: str) -> None:
1919

2020
def get_encoded_credentials(self) -> str:
2121
"""
22-
Returns the Base64 encoded username and password for API authentication.
22+
Returns the Base64 encoded username and password for API
23+
authentication.
2324
"""
2425
credentials = f"{self.username}:{self.password}"
2526
return base64.b64encode(credentials.encode()).decode()
@@ -46,21 +47,26 @@ def __init__(self, base_url: str, api_credentials: APICredentials) -> None:
4647

4748
def req(self, payload: dict, method: str, config: dict) -> dict:
4849
"""
49-
Sends a HTTP request to the specified URL with the given payload and method.
50+
Sends a HTTP request to the specified URL with the given payload
51+
and method.
5052
5153
Args:
5254
payload (dict): The payload to be sent with the request.
53-
method (str): The HTTP method to be used for the request (e.g., "POST", "GET").
54-
config (dict): Additional configuration options for the request.
55+
method (str): The HTTP method to be used for the request
56+
(e.g., "POST", "GET").
57+
config (dict): Additional configuration options for the
58+
request.
5559
5660
Returns:
57-
dict: The JSON response from the server, if the request is successful.
61+
dict: The JSON response from the server, if the request is
62+
successful.
5863
None, if an error occurs during the request.
5964
6065
Raises:
6166
requests.exceptions.Timeout: If the request times out.
6267
requests.exceptions.HTTPError: If an HTTP error occurs.
63-
requests.exceptions.RequestException: If a general request error occurs.
68+
requests.exceptions.RequestException: If a general request
69+
error occurs.
6470
"""
6571
try:
6672
if method == "POST":
@@ -104,7 +110,8 @@ def __init__(self, base_url: str, api_credentials: APICredentials) -> None:
104110
105111
Args:
106112
base_url (str): The base URL of the API.
107-
api_credentials (ApiCredentials): The API credentials used for authorization.
113+
api_credentials (ApiCredentials): The API credentials used for
114+
authorization.
108115
109116
Returns:
110117
None
@@ -181,7 +188,8 @@ async def get_http_resp(
181188
182189
Args:
183190
job_id (str): The ID of the job.
184-
user_session (aiohttp.ClientSession): The client session used for making the request.
191+
user_session (aiohttp.ClientSession): The client session used for
192+
making the request.
185193
186194
Returns:
187195
dict: The JSON response data.

src/oxylabs/sources/ecommerce/amazon/amazon.py

Lines changed: 124 additions & 50 deletions
Large diffs are not rendered by default.

src/oxylabs/sources/ecommerce/google_shopping/google_shopping.py

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ def __init__(self, ecommerce_instance) -> None:
1111
Initializes an instance of the GoogleShopping class.
1212
1313
Args:
14-
ecommerce_instance: The Ecommerce instance associated with the GoogleShopping class.
14+
ecommerce_instance: The Ecommerce instance associated with the
15+
GoogleShopping class.
1516
"""
1617
self._ecommerce_instance = ecommerce_instance
1718

@@ -26,7 +27,8 @@ def scrape_shopping_search(
2627
2728
Args:
2829
query (str): UTF-encoded keyword
29-
opts (dict, optional): Configuration options for the search. Defaults to:
30+
opts (dict, optional): Configuration options for the search.
31+
Defaults to:
3032
{
3133
"domain": com,
3234
"start_page": 1,
@@ -42,7 +44,9 @@ def scrape_shopping_search(
4244
"parsing_instructions": None,
4345
}
4446
This parameter allows customization of the search request.
45-
request_timeout (int | 160, optional): The interval in seconds for the request to time out if no response is returned. Defaults to 160.
47+
request_timeout (int | 165, optional): The interval in seconds for
48+
the request to time out if no response is returned.
49+
Defaults to 165.
4650
4751
Returns:
4852
dict: The response from the server after the job is completed.
@@ -64,7 +68,8 @@ def scrape_shopping_url(
6468
6569
Args:
6670
url (str): Direct URL (link) to Google page
67-
opts (GoogleShoppingUrlOpts, optional): Configuration options for the search. Defaults to:
71+
opts (GoogleShoppingUrlOpts, optional): Configuration options for
72+
the search. Defaults to:
6873
{
6974
"user_agent_type": desktop,
7075
"render": None,
@@ -93,7 +98,8 @@ def scrape_shopping_products(
9398
9499
Args:
95100
query (str): UTF-encoded product code.
96-
opts (GoogleShoppingProductOpts, optional): Configuration options for the search. Defaults to:
101+
opts (GoogleShoppingProductOpts, optional): Configuration options
102+
for the search. Defaults to:
97103
{
98104
"domain": com,
99105
"locale": None,
@@ -125,7 +131,8 @@ def scrape_product_pricing(
125131
126132
Args:
127133
query (str): UTF-encoded product code.
128-
opts (GoogleShoppingUrlOpts, optional): Configuration options for the search. Defaults to:
134+
opts (GoogleShoppingUrlOpts, optional): Configuration options for
135+
the search. Defaults to:
129136
{
130137
"domain": com,
131138
"locale": None,
@@ -155,7 +162,8 @@ def __init__(self, ecommerce_async_instance) -> None:
155162
Initializes an instance of the GoogleShoppingAsync class.
156163
157164
Args:
158-
ecommerce_async_instance: The EcommerceAsync instance associated with the GoogleShoppingAsync class.
165+
ecommerce_async_instance: The EcommerceAsync instance associated
166+
with the GoogleShoppingAsync class.
159167
"""
160168
self._ecommerce_async_instance = ecommerce_async_instance
161169

@@ -172,7 +180,8 @@ async def scrape_shopping_search(
172180
173181
Args:
174182
query (str): UTF-encoded keyword.
175-
opts (dict, optional): Configuration options for the search. Defaults to:
183+
opts (dict, optional): Configuration options for the search.
184+
Defaults to:
176185
{
177186
"domain": com,
178187
"start_page": 1,
@@ -188,8 +197,11 @@ async def scrape_shopping_search(
188197
"parsing_instructions": None,
189198
}
190199
This parameter allows customization of the search request.
191-
request_timeout (int | 160, optional): The interval in seconds for the request to time out if no response is returned. Defaults to 160.
192-
poll_interval (int, optional): The interval in seconds for the request to poll the server for a response. Defaults to 2.
200+
request_timeout (int | 165, optional): The interval in seconds for
201+
the request to time out if no response is returned.
202+
Defaults to 165.
203+
poll_interval (int, optional): The interval in seconds for the
204+
request to poll the server for a response. Defaults to 5.
193205
194206
Returns:
195207
dict: The response from the server after the job is completed.
@@ -220,7 +232,8 @@ async def scrape_shopping_url(
220232
221233
Args:
222234
url (str): Direct URL (link) to Google page.
223-
opts (GoogleShoppingUrlOpts, optional): Configuration options for the search. Defaults to:
235+
opts (GoogleShoppingUrlOpts, optional): Configuration options for
236+
the search. Defaults to:
224237
{
225238
"user_agent_type": desktop,
226239
"render": None,
@@ -229,8 +242,11 @@ async def scrape_shopping_url(
229242
"parse": None,
230243
"parsing_instructions": None,
231244
}
232-
request_timeout (int | 160, optional): The interval in seconds for the request to time out if no response is returned. Defaults to 160.
233-
poll_interval (int, optional): The interval in seconds for the request to poll the server for a response. Defaults to 2.
245+
request_timeout (int | 165, optional): The interval in seconds
246+
for the request to time out if no response is returned.
247+
Defaults to 165.
248+
poll_interval (int, optional): The interval in seconds for the
249+
request to poll the server for a response. Defaults to 5.
234250
Returns:
235251
dict: The response from the server after the job is completed.
236252
"""
@@ -260,7 +276,8 @@ async def scrape_shopping_products(
260276
261277
Args:
262278
query (str): UTF-encoded product code.
263-
opts (GoogleShoppingProductOpts, optional): Configuration options for the search. Defaults to:
279+
opts (GoogleShoppingProductOpts, optional): Configuration options
280+
for the search. Defaults to:
264281
{
265282
"domain": com,
266283
"locale": None,
@@ -272,8 +289,11 @@ async def scrape_shopping_products(
272289
"parse": None,
273290
"parsing_instructions": None,
274291
}
275-
request_timeout (int | 160, optional): The interval in seconds for the request to time out if no response is returned. Defaults to 160.
276-
poll_interval (int, optional): The interval in seconds for the request to poll the server for a response. Defaults to 2.
292+
request_timeout (int | 165, optional): The interval in seconds for
293+
the request to time out if no response is returned.
294+
Defaults to 165.
295+
poll_interval (int, optional): The interval in seconds for the
296+
request to poll the server for a response. Defaults to 5.
277297
Returns:
278298
dict: The response from the server after the job is completed.
279299
"""
@@ -303,7 +323,8 @@ async def scrape_product_pricing(
303323
304324
Args:
305325
url (str): UTF-encoded product code.
306-
opts (GoogleShoppingUrlOpts, optional): Configuration options for the search. Defaults to:
326+
opts (GoogleShoppingUrlOpts, optional): Configuration options for
327+
the search. Defaults to:
307328
{
308329
"domain": com,
309330
"start_page": 1,
@@ -317,8 +338,11 @@ async def scrape_product_pricing(
317338
"parse": None,
318339
"parsing_instructions": None,
319340
}
320-
request_timeout (int | 160, optional): The interval in seconds for the request to time out if no response is returned. Defaults to 160.
321-
poll_interval (int, optional): The interval in seconds for the request to poll the server for a response. Defaults to 2.
341+
request_timeout (int | 165, optional): The interval in seconds for
342+
the request to time out if no response is returned.
343+
Defaults to 165.
344+
poll_interval (int, optional): The interval in seconds for the
345+
request to poll the server for a response. Defaults to 5.
322346
Returns:
323347
dict: The response from the server after the job is completed.
324348
"""

src/oxylabs/sources/ecommerce/google_shopping/google_shopping_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ def _prepare_shopping_product_pricing_payload(
249249
self, query: str, user_opts: Optional[dict] = None
250250
) -> dict:
251251
"""
252-
Prepares the payload for retrieving product pricing from Google Shopping.
252+
Prepares the payload for retrieving product pricing from
253+
Google Shopping.
253254
254255
Args:
255256
query (str): The search query for the products.

src/oxylabs/sources/ecommerce/universal/universal.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def scrape_url(
4040
"parsing_instructions": None,
4141
}
4242
This parameter allows customization of the search request.
43-
request_timeout (int | 160, optional): The interval in seconds for the request to time out if no response is returned. Defaults to 160.
43+
request_timeout (int | 165, optional): The interval in seconds for
44+
the request to time out if no response is returned.
45+
Defaults to 165.
4446
4547
Returns:
4648
dict: The response from the server after the job is completed.
@@ -89,9 +91,14 @@ async def scrape_url(
8991
"parsing_instructions": None,
9092
}
9193
This parameter allows customization of the search request.
92-
request_timeout (int | 160, optional): The interval in seconds for the request to time out if no response is returned. Defaults to 160.
93-
poll_interval (int | 5, optional): The interval in seconds to poll the server for a response. Defaults to 5
94-
job_completion_timeout (int | 50, optional): The interval in seconds for the job to time out if no response is returned. Defaults to 50.
94+
request_timeout (int | 165, optional): The interval in seconds for
95+
the request to time out if no response is returned.
96+
Defaults to 165.
97+
poll_interval (int | 5, optional): The interval in seconds to poll
98+
the server for a response. Defaults to 5
99+
job_completion_timeout (int | 50, optional): The interval in
100+
seconds for the job to time out if no response is returned.
101+
Defaults to 50.
95102
96103
Returns:
97104
dict: The response from the server after the job is completed.

src/oxylabs/sources/ecommerce/wayfair/wayfair.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ def __init__(self, ecommerce_instance) -> None:
1111
Initializes an instance of the Wayfair class.
1212
1313
Args:
14-
ecommerce_instance: The Ecommerce instance associated with the Wayfair class.
14+
ecommerce_instance: The Ecommerce instance associated with the
15+
Wayfair class.
1516
"""
1617
self._ecommerce_instance = ecommerce_instance
1718

@@ -26,7 +27,8 @@ def scrape_search(
2627
2728
Args:
2829
query (str): The search query.
29-
opts (dict, optional): Configuration options for the search. Defaults to:
30+
opts (dict, optional): Configuration options for the search.
31+
Defaults to:
3032
{
3133
"start_page": 1,
3234
"pages": 1,
@@ -36,7 +38,9 @@ def scrape_search(
3638
"parsing_instructions": None,
3739
}
3840
This parameter allows customization of the search request.
39-
request_timeout (int | 160, optional): The interval in seconds for the request to time out if no response is returned. Defaults to 160.
41+
request_timeout (int | 165, optional): The interval in seconds for
42+
the request to time out if no response is returned.
43+
Defaults to 165.
4044
4145
Returns:
4246
dict: The response from the server after the job is completed.
@@ -58,14 +62,17 @@ def scrape_url(
5862
5963
Args:
6064
url (str): The URL to be scraped.
61-
opts (WayfairUrlOpts, optional): Configuration options for the search. Defaults to:
65+
opts (WayfairUrlOpts, optional): Configuration options for the
66+
search. Defaults to:
6267
{
6368
"user_agent_type": desktop,
6469
"callback_url": None,
6570
"parsing_instructions": None,
6671
}
6772
This parameter allows customization of the search request.
68-
request_timeout (int | 160, optional): The interval in seconds for the request to time out if no response is returned. Defaults to 160.
73+
request_timeout (int | 165, optional): The interval in seconds for
74+
the request to time out if no response is returned.
75+
Defaults to 165.
6976
7077
Returns:
7178
dict: The response from the server after the job is completed.
@@ -83,7 +90,8 @@ def __init__(self, ecommerce_async_instance) -> None:
8390
Initializes an instance of the WayfairAsync class.
8491
8592
Args:
86-
ecommerce_async_instance: The EcommerceAsync instance associated with the WayfairAsync class.
93+
ecommerce_async_instance: The EcommerceAsync instance associated
94+
with the WayfairAsync class.
8795
"""
8896
self._ecommerce_async_instance = ecommerce_async_instance
8997

@@ -100,7 +108,8 @@ async def scrape_search(
100108
101109
Args:
102110
query (str): The search query.
103-
opts (dict, optional): Configuration options for the search. Defaults to:
111+
opts (dict, optional): Configuration options for the search.
112+
Defaults to:
104113
{
105114
"start_page": 1,
106115
"pages": 1,
@@ -110,9 +119,14 @@ async def scrape_search(
110119
"parsing_instructions": None,
111120
}
112121
This parameter allows customization of the search request.
113-
request_timeout (int | 160, optional): The interval in seconds for the request to time out if no response is returned. Defaults to 160.
114-
poll_interval (int | 5, optional): The interval in seconds to poll the server for a response. Defaults to 5
115-
job_completion_timeout (int | 50, optional): The interval in seconds for the job to time out if no response is returned. Defaults to 50
122+
request_timeout (int | 165, optional): The interval in seconds for
123+
the request to time out if no response is returned.
124+
Defaults to 165.
125+
poll_interval (int | 5, optional): The interval in seconds to poll
126+
the server for a response. Defaults to 5
127+
job_completion_timeout (int | 50, optional): The interval in
128+
seconds for the job to time out if no response is returned.
129+
Defaults to 50
116130
117131
Returns:
118132
dict: The response from the server after the job is completed.
@@ -143,16 +157,22 @@ async def scrape_url(
143157
144158
Args:
145159
url (str): The URL to be scraped.
146-
opts (WayfairUrlOpts, optional): Configuration options for the search. Defaults to:
160+
opts (WayfairUrlOpts, optional): Configuration options for the
161+
search. Defaults to:
147162
{
148163
"user_agent_type": desktop,
149164
"callback_url": None,
150165
"parsing_instructions": None,
151166
}
152167
This parameter allows customization of the search request.
153-
request_timeout (int | 160, optional): The interval in seconds for the request to time out if no response is returned. Defaults to 160.
154-
poll_interval (int | 5, optional): The interval in seconds to poll the server for a response. Defaults to 5
155-
job_completion_timeout (int | 50, optional): The interval in seconds for the job to time out if no response is returned. Defaults to 50
168+
request_timeout (int | 165, optional): The interval in seconds for
169+
the request to time out if no response is returned.
170+
Defaults to 165.
171+
poll_interval (int | 5, optional): The interval in seconds to poll
172+
the server for a response. Defaults to 5
173+
job_completion_timeout (int | 50, optional): The interval in
174+
seconds for the job to time out if no response is returned.
175+
Defaults to 50
156176
157177
Returns:
158178
dict: The response from the server after the job is completed.

src/oxylabs/sources/ecommerce/wayfair/wayfair_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ def _prepare_url_payload(
9797
user_opts (dict): Optional user-defined options.
9898
9999
Returns:
100-
dict: The prepared payload containing the source, URL, user agent type, and callback URL.
100+
dict: The prepared payload containing the source, URL, user agent
101+
type, and callback URL.
101102
102103
Raises:
103104
ValidationError: If the URL is invalid.

0 commit comments

Comments
 (0)