瀏覽代碼

SB_iter_keywords

huangyifan 1 年之前
父節點
當前提交
fd6b15fc68
共有 1 個文件被更改,包括 13 次插入1 次删除
  1. 13 1
      sync_amz_data/public/amz_ad_client.py

+ 13 - 1
sync_amz_data/public/amz_ad_client.py

@@ -294,10 +294,22 @@ class SBClient(BaseClient):
                 break
             body["nextToken"] = info["nextToken"]
 
-    def get_keywords(self):
+    def get_keywords(self,**param):
         url_path = "/sb/keywords"
         return self._request(url_path, method="GET")
 
+    def iter_keywords(self,**param):
+        if "startIndex" not in param:
+            param["startIndex"] = 0
+            param["count"] = 5000
+        while True:
+            info:list = self.get_keywords(**param)
+            # print(info)
+            if len(info)==0:
+                break
+            param["startIndex"] += 5000
+            yield info
+
     def get_targets(self, **body):
         url_path = "/sb/targets/list"
         return self._request(url_path, method="POST", body=body)