Skip to content

Commit 4ae62c5

Browse files
author
Anonymous Committer
committed
feat: add taobao.get_item_comment_v1 with pagination handling and test case
1 parent f76d9bc commit 4ae62c5

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

justoneapi/apis/taobao.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,25 @@ def get_item_detail_v9(self, item_id: str):
7171
}
7272
return request_util.get_request(url, params)
7373

74+
def get_item_comment_v1(self, item_id: str, page: int = 1, order_type: str = "feedbackdate"):
75+
url = f"{self.base_url}/api/taobao/get-item-comment/v1"
76+
params = {
77+
"token": self.token,
78+
"itemId": item_id,
79+
"page": page,
80+
"orderType": order_type,
81+
}
82+
83+
has_next_page = False
84+
result, data, message = request_util.get_request_page(url, params)
85+
try:
86+
if data:
87+
if data.get("hasNext") == "true":
88+
has_next_page = True
89+
except Exception as e:
90+
logger.warning(f"Pagination parse error at {url}. Contact us to fix it.")
91+
return result, data, message, has_next_page
92+
7493
def get_item_comment_v6(self, item_id: str, page: int, order_type: str = None):
7594
url = f"{self.base_url}/api/taobao/get-item-comment/v6"
7695
params = {

tests/test_taobao.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,7 @@ def test_search_item_list_v1(self):
7878
if result:
7979
print(json.dumps(data, ensure_ascii=False))
8080

81+
def test_get_item_comment_v1(self):
82+
result, data, message, has_next_page = self.client.taobao.get_item_comment_v1(item_id="988779079569")
83+
if result:
84+
print(json.dumps(data, ensure_ascii=False))

0 commit comments

Comments
 (0)