|
@@ -0,0 +1,44 @@
|
|
|
+import requests
|
|
|
+from urllib.parse import urljoin
|
|
|
+from sync_amz_data.tasks.datainsert.wg import LADS
|
|
|
+
|
|
|
+
|
|
|
+class RateLimitError(Exception):
|
|
|
+ def __init__(self, retry_after: str = None):
|
|
|
+ self.retry_after = retry_after
|
|
|
+
|
|
|
+
|
|
|
+def request(url_path: str, method: str = "GET", head: dict = None, params: dict = None, body: dict = None, AD=LADS):
|
|
|
+ ADS = AD
|
|
|
+ resp = requests.session().request(
|
|
|
+ method=method,
|
|
|
+ url=urljoin(ADS, url_path),
|
|
|
+ headers=head,
|
|
|
+ params=params,
|
|
|
+ json=body,
|
|
|
+ )
|
|
|
+ if resp.status_code == 429:
|
|
|
+ raise RateLimitError(resp.headers.get("Retry-After"))
|
|
|
+ if resp.status_code >= 400:
|
|
|
+ raise Exception(resp.text)
|
|
|
+ return resp.json()
|
|
|
+
|
|
|
+
|
|
|
+class Categories:
|
|
|
+ def __init__(self, profile_id):
|
|
|
+ self.profile_id = profile_id
|
|
|
+ self.upcreate_url_path = "api/ad_manage/targetable/categories/updata/"
|
|
|
+ self.heads = {'X-Token': "da4ab6bc5cbf1dfa"}
|
|
|
+
|
|
|
+ def updata_create(self):
|
|
|
+ heads = self.heads
|
|
|
+ url_path = self.upcreate_url_path
|
|
|
+ params = {"profile_id": self.profile_id}
|
|
|
+ tem = request(url_path=url_path, head=heads, method="GET", params=params)
|
|
|
+ return tem
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ a = Categories(profile_id="3006125408623189")
|
|
|
+ out = a.updata_create()
|
|
|
+ print(out)
|