Skip to content

Commit b9e3c7b

Browse files
Add methods for Walmart and Target reviews (#38)
1 parent 136af05 commit b9e3c7b

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

outscraper/client.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,3 +1386,77 @@ def yellowpages_search(self, query: Union[list, str], location: str = 'New York,
13861386
}
13871387

13881388
return self._request('GET', '/yellowpages-search', wait_async=wait_async, async_request=async_request, params=params)
1389+
1390+
def wallmart_reviews(self, query: Union[list, str], limit: int = 100, sort: str = 'relevancy', cutoff: int = None,
1391+
fields: Union[list, str] = None, async_request: bool = False, ui: bool = None, webhook: str = None
1392+
) -> Union[list, dict]:
1393+
'''
1394+
Returns reviews from a list of products.
1395+
1396+
Parameters:
1397+
query (list | str): Links to Walmart products (e.g., https://www.walmart.com/ip/Blackstone-Original-4-Burner-36-Propane-Omnivore-Griddle-with-Hard-Cover/1347629739). Using a lists allows multiple queries (up to 1000) to be sent in one request and save on network latency time.
1398+
limit (int): parameter specifies the limit of reviews to get from one query.
1399+
sort (str): parameter specifies one of the sorting types. Available values: "relevancy", "helpful", "submission-desc", "submission-asc", "rating-desc", "rating-asc".
1400+
cutoff (int): parameter specifies the oldest timestamp value for items. Using the cutoff parameter overwrites sort parameter to most recent.
1401+
fields (list | str): parameter defines which fields you want to include with each item returned in the response. By default, it returns all fields.
1402+
async_request (bool): parameter defines the way you want to submit your task to Outscraper. It can be set to `False` (default) to send a task and wait until you got your results, or `True` to submit your task and retrieve the results later using a request ID with `get_request_archive`. Each response is available for `2` hours after a request has been completed.
1403+
ui (bool): parameter defines whether a task will be executed as a UI task. This is commonly used when you want to create a regular platform task with API. Using this parameter overwrites the async_request parameter to `True`.
1404+
webhook (str): parameter defines the URL address (callback) to which Outscraper will create a POST request with a JSON body once a task/request is finished. Using this parameter overwrites the webhook from integrations.
1405+
1406+
Returns:
1407+
list|dict: JSON result
1408+
1409+
See: https://app.outscraper.cloud/api-docs#tag/reviews--comments/GET/walmart-reviews
1410+
'''
1411+
1412+
queries = as_list(query)
1413+
wait_async = async_request or limit > 499 or len(queries) > 10
1414+
params = {
1415+
'query': queries,
1416+
'limit': limit,
1417+
'sort': sort,
1418+
'cutoff': cutoff,
1419+
'async': wait_async,
1420+
'fields': parse_fields(fields),
1421+
'ui': ui,
1422+
'webhook': webhook,
1423+
}
1424+
1425+
return self._request('GET', '/walmart-reviews', wait_async=wait_async, async_request=async_request, params=params)
1426+
1427+
def target_reviews(self, query: Union[list, str], limit: int = 100, sort: str = 'most_recent', cutoff: int = None,
1428+
fields: Union[list, str] = None, async_request: bool = False, ui: bool = None, webhook: str = None
1429+
) -> Union[list, dict]:
1430+
'''
1431+
Returns reviews from a list of products.
1432+
1433+
Parameters:
1434+
query (list | str): Links to Target products (e.g., https://www.target.com/p/apple-iphone-15-pro-max/-/A-89957794). Using a lists allows multiple queries (up to 1000) to be sent in one request and save on network latency time.
1435+
limit (int): parameter specifies the limit of reviews to get from one query.
1436+
sort (str): parameter specifies one of the sorting types. Available values: "most_recent", "highest_rating", "lowest_rating", "helpfulness_desc".
1437+
cutoff (int): parameter specifies the oldest timestamp value for items. Using the cutoff parameter overwrites sort parameter to most recent.
1438+
fields (list | str): parameter defines which fields you want to include with each item returned in the response. By default, it returns all fields.
1439+
async_request (bool): parameter defines the way you want to submit your task to Outscraper. It can be set to `False` (default) to send a task and wait until you got your results, or `True` to submit your task and retrieve the results later using a request ID with `get_request_archive`. Each response is available for `2` hours after a request has been completed.
1440+
ui (bool): parameter defines whether a task will be executed as a UI task. This is commonly used when you want to create a regular platform task with API. Using this parameter overwrites the async_request parameter to `True`.
1441+
webhook (str): parameter defines the URL address (callback) to which Outscraper will create a POST request with a JSON body once a task/request is finished. Using this parameter overwrites the webhook from integrations.
1442+
1443+
Returns:
1444+
list|dict: JSON result
1445+
1446+
See: https://app.outscraper.cloud/api-docs#tag/reviews--comments/GET/target-reviews
1447+
'''
1448+
1449+
queries = as_list(query)
1450+
wait_async = async_request or limit > 499 or len(queries) > 10
1451+
params = {
1452+
'query': queries,
1453+
'limit': limit,
1454+
'sort': sort,
1455+
'cutoff': cutoff,
1456+
'async': wait_async,
1457+
'fields': parse_fields(fields),
1458+
'ui': ui,
1459+
'webhook': webhook,
1460+
}
1461+
1462+
return self._request('GET', '/target-reviews', wait_async=wait_async, async_request=async_request, params=params)

0 commit comments

Comments
 (0)