Skip to content

Commit b08b1b7

Browse files
author
Anonymous Committer
committed
feat: add taobao.get_shop_item_list_v1
1 parent 1020ce6 commit b08b1b7

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

justoneapi/apis/taobao.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,27 @@ def get_social_feed_v1(self, item_id: str, page: int):
105105
logger.warning(f"Pagination parse error at {url}. Contact us to fix it.")
106106
return result, data, message, has_next_page
107107

108+
def get_shop_item_list_v1(self, user_id: str, shop_id: str, page: int, sort: str = None):
109+
url = f"{self.base_url}/api/taobao/get-shop-item-list/v1"
110+
params = {
111+
"token": self.token,
112+
"userId": user_id,
113+
"shopId": shop_id,
114+
"page": page,
115+
}
116+
if sort:
117+
params["sort"] = sort
118+
119+
has_next_page = False
120+
result, data, message = request_util.get_request_page(url, params)
121+
try:
122+
if data:
123+
if data.get("pageInitialProps", {}).get("httpData", {}).get("itemListModuleResponse", {}).get("page", {}).get("totalPages", 0) > page:
124+
has_next_page = True
125+
except Exception as e:
126+
logger.warning(f"Pagination parse error at {url}. Contact us to fix it.")
127+
return result, data, message, has_next_page
128+
108129
def get_shop_item_list_v9(self, user_id: str, shop_id: str, sort: str, page: int):
109130
url = f"{self.base_url}/api/taobao/get-shop-item-list/v9"
110131
params = {

tests/test_taobao.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ def test_get_item_sale_v5(self):
6161
print(json.dumps(data, ensure_ascii=False))
6262

6363
def test_search_item_list_v6(self):
64-
result, data, message, has_next_page = self.client.taobao.search_item_list_v6(keyword="deepseek", sort="_sale", page=1)
64+
result, data, message, has_next_page = self.client.taobao.search_item_list_v6(keyword="deepseek", sort="_sale",
65+
page=1)
66+
if result:
67+
print(json.dumps(data, ensure_ascii=False))
68+
69+
def test_get_shop_item_list_v1(self):
70+
result, data, message, has_next_page = self.client.taobao.get_shop_item_list_v1(user_id="2824260419", shop_id="151272028", page=1)
6571
if result:
6672
print(json.dumps(data, ensure_ascii=False))

0 commit comments

Comments
 (0)