|
@@ -262,6 +262,32 @@ class SBClient(BaseClient):
|
|
if not info.get("nextToken"):
|
|
if not info.get("nextToken"):
|
|
break
|
|
break
|
|
body["nextToken"] = info["nextToken"]
|
|
body["nextToken"] = info["nextToken"]
|
|
|
|
+ def get_keywords(self):
|
|
|
|
+ url_path = "/sb/keywords"
|
|
|
|
+ return self._request(url_path, method="GET")
|
|
|
|
+
|
|
|
|
+ def get_targets(self,**body):
|
|
|
|
+ url_path = "/sb/targets/list"
|
|
|
|
+ return self._request(url_path, method="POST", body=body)
|
|
|
|
+
|
|
|
|
+ def iter_targets(self,**body):
|
|
|
|
+ if "maxResults" not in body:
|
|
|
|
+ body["maxResults"] = 100
|
|
|
|
+ while True:
|
|
|
|
+ info: dict = self.get_targets(**body)
|
|
|
|
+ # print(info)
|
|
|
|
+ yield from info["targets"]
|
|
|
|
+ if not info.get("nextToken"):
|
|
|
|
+ break
|
|
|
|
+ body["nextToken"] = info["nextToken"]
|
|
|
|
+
|
|
|
|
+ def get_budget(self,campaignIds:list):
|
|
|
|
+ url_path = "/sb/campaigns/budget/usage"
|
|
|
|
+ body = {"campaignIds":campaignIds}
|
|
|
|
+ return self._request(url_path, method="POST",body=body)
|
|
|
|
+ def get_keyword_bidrecommendation(self,**body):
|
|
|
|
+ url_path = "/sb/recommendations/bids"
|
|
|
|
+ return self._request(url_path, method="POST", body=body)
|
|
|
|
|
|
def get_report(
|
|
def get_report(
|
|
self,
|
|
self,
|
|
@@ -348,8 +374,9 @@ if __name__ == '__main__':
|
|
# sp = SPClient(**AWS_CREDENTIALS)
|
|
# sp = SPClient(**AWS_CREDENTIALS)
|
|
# print(sp.get_keyword_bidrecommendation(adGroupId="119753215871672",keyword=["8mp security camera system","8mp security camera system"],matchType=["broad","exact"]))
|
|
# print(sp.get_keyword_bidrecommendation(adGroupId="119753215871672",keyword=["8mp security camera system","8mp security camera system"],matchType=["broad","exact"]))
|
|
sb = SBClient(**AWS_CREDENTIALS)
|
|
sb = SBClient(**AWS_CREDENTIALS)
|
|
- print(list(sb.iter_ads()))
|
|
|
|
-
|
|
|
|
|
|
+ # print(list(sb.iter_targets()))
|
|
|
|
+ print(sb.get_keyword_bidrecommendation(**{'campaignId': 27333596383941,'keywords':[{"matchType":'broad',"keywordText":"4k security camera system"}]}))
|
|
|
|
+ print(sb.get_budget([27333596383941]))
|
|
# sd = SDClient(**AWS_CREDENTIALS)
|
|
# sd = SDClient(**AWS_CREDENTIALS)
|
|
# print(sd.get_campaigns(startIndex=10, count=10))
|
|
# print(sd.get_campaigns(startIndex=10, count=10))
|
|
|
|
|