lazyad 0.0.37__py3-none-any.whl → 0.0.40__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of lazyad might be problematic. Click here for more details.

@@ -0,0 +1,193 @@
1
+ from lazysdk import lazyrequests
2
+ from lazysdk import lazytime
3
+ import copy
4
+
5
+
6
+ """
7
+ 官网:https://adv.mintegral.com/cn/login
8
+ """
9
+ default_headers = {
10
+ "Accept": "application/json, text/plain, */*",
11
+ "Accept-Encoding": "gzip, deflated",
12
+ "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
13
+ "Cache-Control": "no-cache",
14
+ "Connection": "keep-alive",
15
+ "Cookie": "",
16
+ "Host": "ss-api.mintegral.com",
17
+ "Origin": "https://adv.mintegral.com",
18
+ "Pragma": "no-cache",
19
+ "Referer": "https://adv.mintegral.com/cn/login",
20
+ "Sec-Fetch-Dest": "empty",
21
+ "Sec-Fetch-Mode": "cors",
22
+ "Sec-Fetch-Site": "same-site",
23
+ "Sec-GPC": "1",
24
+ "TE": "trailers",
25
+ "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:132.0) Gecko/20100101 Firefox/132.0"
26
+ }
27
+
28
+
29
+ def auth(
30
+ cookie: str
31
+ ):
32
+ """
33
+ 验证cookie是否有效
34
+ 需要登录:{'code': 400, 'msg': 'Please login first', 'data': None}
35
+ 验证成功:{'code': 200, 'msg': 'success', 'data': {}
36
+
37
+ """
38
+ url = "https://ss-api.mintegral.com/api/v1/auth"
39
+ headers = copy.deepcopy(default_headers)
40
+ headers["Cookie"] = cookie
41
+ return lazyrequests.lazy_requests(
42
+ method="GET",
43
+ url=url,
44
+ headers=headers
45
+ )
46
+
47
+
48
+ def options(
49
+ cookie: str
50
+ ):
51
+ """
52
+ 获取系统的基本选项
53
+ 需要登录:{'code': 400, 'msg': 'Please login first', 'data': None}
54
+ 验证成功:
55
+ {
56
+ 'code': 200,
57
+ 'msg': 'success',
58
+ 'data': {
59
+ 'offer': ...,
60
+ 'campaign': ...,
61
+ ...
62
+ }
63
+ }
64
+ """
65
+ scheme = "https"
66
+ host = "ss-api.mintegral.com"
67
+ filename = "/api/v1/options/_batch"
68
+ params = {
69
+ "query": "offer,campaign,offer-status,billing-type,country,timezone,country-region-city"
70
+ }
71
+ url = f"{scheme}://{host}{filename}"
72
+ headers = copy.deepcopy(default_headers)
73
+ headers["Cookie"] = cookie
74
+ return lazyrequests.lazy_requests(
75
+ method="GET",
76
+ params=params,
77
+ url=url,
78
+ headers=headers
79
+ )
80
+
81
+
82
+ def offers(
83
+ cookie: str,
84
+ offer_id: int = None,
85
+ method: str = "GET",
86
+ put_data: dict = None,
87
+ page: int = 1,
88
+ page_size: int = 50
89
+ ):
90
+ """
91
+ 获取广告单元列表
92
+ 需要登录:{'code': 400, 'msg': 'Please login first', 'data': None}
93
+ 验证成功:{'code': 200, 'msg': 'success', 'data': {}
94
+ """
95
+ scheme = "https"
96
+ host = "ss-api.mintegral.com"
97
+ if not offer_id:
98
+ filename = "/api/v1/offers"
99
+ params = {
100
+ "limit": page_size,
101
+ "page": page,
102
+ "order": "DESC",
103
+ "sort": "id"
104
+ }
105
+ else:
106
+ filename = f"/api/v1/offers/{offer_id}"
107
+ if method == "PUT":
108
+ params = put_data
109
+ else:
110
+ params = {}
111
+
112
+ url = f"{scheme}://{host}{filename}"
113
+ headers = copy.deepcopy(default_headers)
114
+ headers["Cookie"] = cookie
115
+ return lazyrequests.lazy_requests(
116
+ method=method,
117
+ params=params,
118
+ url=url,
119
+ headers=headers
120
+ )
121
+
122
+
123
+ def performance(
124
+ cookie: str,
125
+ page: int = 1,
126
+ page_size: int = 50,
127
+ timezone: int = 8,
128
+ start_time: str = None,
129
+ end_time: str = None,
130
+ show_calendar_day: int = 2,
131
+ total: bool = False,
132
+ breakdowns: list = None,
133
+ metrics: list = None
134
+ ):
135
+ """
136
+ 获取广告单元列表
137
+ 需要登录:{'code': 400, 'msg': 'Please login first', 'data': None}
138
+ 验证成功:{'code': 200, 'msg': 'success', 'data': {}
139
+ """
140
+ scheme = "https"
141
+ host = "ss-api.mintegral.com"
142
+ filename = "/api/v1/reports/performance"
143
+ filename_total = "/api/v1/reports/performance-total"
144
+ if not start_time:
145
+ start_time = lazytime.get_date_string(days=0)
146
+ if not end_time:
147
+ end_time = lazytime.get_date_string(days=0)
148
+ if not breakdowns:
149
+ breakdowns = ["date", "adv_offer_id"]
150
+ if not metrics:
151
+ metrics = [
152
+ "adv_impression",
153
+ "adv_click",
154
+ "adv_install",
155
+ "ecpm",
156
+ "ecpc",
157
+ "ecpi",
158
+ "ctr",
159
+ "ivr",
160
+ "cvr",
161
+ "adv_original_money",
162
+ "iaa_d0_ad_revenue",
163
+ "iaa_d0_roas"
164
+ ]
165
+ params = {
166
+ "limit": page_size,
167
+ "page": page,
168
+ "timezone": timezone,
169
+ "start_time": start_time,
170
+ "end_time": end_time,
171
+ "order": "DESC",
172
+ "breakdowns": ",".join(breakdowns),
173
+ "metrics": ",".join(metrics),
174
+ "show_calendar_day": show_calendar_day
175
+ }
176
+ url = f"{scheme}://{host}{filename}"
177
+ url_total = f"{scheme}://{host}{filename_total}"
178
+ headers = copy.deepcopy(default_headers)
179
+ headers["Cookie"] = cookie
180
+ if total:
181
+ return lazyrequests.lazy_requests(
182
+ method="GET",
183
+ params=params,
184
+ url=url_total,
185
+ headers=headers
186
+ )
187
+ else:
188
+ return lazyrequests.lazy_requests(
189
+ method="GET",
190
+ params=params,
191
+ url=url,
192
+ headers=headers
193
+ )
lazyad/crawlers/qq.py CHANGED
@@ -98,3 +98,82 @@ def new_account_list(
98
98
  headers=temp_headers,
99
99
  json=data
100
100
  )
101
+
102
+
103
+ def account_list_v30(
104
+ cookie: str,
105
+ user_id: int,
106
+ business_id: int,
107
+ start_date: str = None,
108
+ end_date: str = None,
109
+ page: int = 1,
110
+ page_size: int = 20,
111
+ account_id: int = None, # 支持按户id搜索
112
+ account_status: int = 1,
113
+ sort_seq: str = None,
114
+ sort_field: str = None,
115
+ platform_type: int = 1
116
+ ):
117
+ """
118
+ 概览-账户 ADQ3.0账户列表
119
+ :param cookie:
120
+ :param user_id: 登录用户的id
121
+ :param business_id: 大户id
122
+ :param start_date:
123
+ :param end_date:
124
+ :param page:
125
+ :param page_size:
126
+ :param account_id: 子户id
127
+ :param account_status: 账户状态
128
+ 1:有效
129
+ 2:待审核
130
+ 3:审核不通过
131
+ 4:封停
132
+ 21:临时冻结
133
+ :return:
134
+ """
135
+ if not start_date:
136
+ start_date = lazytime.get_date_string(days=-1)
137
+ if not end_date:
138
+ end_date = lazytime.get_date_string(days=-1)
139
+ url = "https://ad.qq.com/tap/v1/account_daily_report/new_account_list?unicode=1&post_format=json"
140
+ temp_headers = copy.deepcopy(default_headers)
141
+ temp_headers["Cookie"] = cookie
142
+ data = {
143
+ "new_source": 1,
144
+ "user_id": user_id,
145
+ "page": page,
146
+ "page_size": page_size,
147
+ "need_sync": True,
148
+ "sync_param_ready": True,
149
+ "business_id_list": [
150
+ business_id
151
+ ],
152
+ "dynamic_field_list": [
153
+ "corporation_name",
154
+ "corporation_alias",
155
+ "rule_target_enable",
156
+ "derive_status",
157
+ "comment", # 标签
158
+ "cost" # 消耗
159
+ ],
160
+ "time_line": "REQUEST_TIME",
161
+ "start_date_millons": lazytime.get_date2timestamp(date=start_date) * 1000, # 开始时间的时间戳
162
+ "end_date_millons": lazytime.get_date2timestamp(date=end_date) * 1000, # 结束时间的时间戳
163
+ "account_status": account_status,
164
+ "platform_type": platform_type,
165
+ "use_top_sort": True,
166
+ "filter_empty_data": 0
167
+ }
168
+ if account_id:
169
+ data["account_id"] = [account_id]
170
+ if sort_seq:
171
+ data["sort_seq"] = sort_seq # desc:降序排序,会自动过滤0数据
172
+ if sort_field:
173
+ data["sort_field"] = sort_field # cost:按照消耗排序
174
+ return lazyrequests.lazy_requests(
175
+ method="POST",
176
+ url=url,
177
+ headers=temp_headers,
178
+ json=data
179
+ )
lazyad/open/qq.py CHANGED
@@ -1,5 +1,5 @@
1
- import showlog
2
1
  from lazysdk import lazyrequests
2
+ import showlog
3
3
  import random
4
4
  import time
5
5
  import json
@@ -157,3 +157,104 @@ def get_organization_account_relation(
157
157
  url=url,
158
158
  params=params
159
159
  )
160
+
161
+
162
+ def get_advertiser_daily_budget(
163
+ access_token: str,
164
+ account_id
165
+ ):
166
+ """
167
+ 版本:3.0
168
+ 获取广告账户日预算
169
+ https://developers.e.qq.com/v3.0/docs/api/advertiser_daily_budget/get
170
+ :param access_token:
171
+ :param account_id:
172
+ :return:
173
+
174
+ 应答示例
175
+ {
176
+ "code": 0,
177
+ "message": "",
178
+ "message_cn": "",
179
+ "data": {
180
+ "account_id": "<ACCOUNT_ID>",
181
+ "daily_budget": 20000,
182
+ "min_daily_budget": 10000
183
+ }
184
+ }
185
+ """
186
+ url = 'https://api.e.qq.com/v3.0/advertiser_daily_budget/get'
187
+ params = {
188
+ 'access_token': access_token,
189
+ 'timestamp': int(time.time()),
190
+ 'nonce': make_nonce(),
191
+
192
+ "account_id": account_id,
193
+ "fields": [
194
+ "account_id",
195
+ "daily_budget"
196
+ ]
197
+ }
198
+ return lazyrequests.lazy_requests(
199
+ method="GET",
200
+ url=url,
201
+ params=params
202
+ )
203
+
204
+
205
+ def update_daily_budget(
206
+ access_token: str,
207
+ account_id: int = None,
208
+ daily_budget: int = None,
209
+ update_daily_budget_spec: list = None
210
+ ):
211
+ """
212
+ 版本:3.0
213
+ 批量修改广告主日限额
214
+ https://developers.e.qq.com/v3.0/docs/api/advertiser/update_daily_budget
215
+ :param access_token:
216
+ :param account_id:
217
+ :param daily_budget: 账户预算,单位为分
218
+ :param update_daily_budget_spec: 任务列表,[{"account_id":"aaa","daily_budget": 100},{"account_id":"bbb","daily_budget": 100}]
219
+ :return:
220
+
221
+ 应答示例
222
+ {
223
+ "code": 0,
224
+ "message": "",
225
+ "message_cn": "",
226
+ "data": {
227
+ "list": [
228
+ {
229
+ "code": 0,
230
+ "message": "",
231
+ "message_cn": "",
232
+ "account_id": "<ACCOUNT_ID>"
233
+ }
234
+ ],
235
+ "fail_id_list": []
236
+ }
237
+ }
238
+ """
239
+ url = 'https://api.e.qq.com/v3.0/advertiser/update_daily_budget'
240
+ params = {
241
+ 'access_token': access_token,
242
+ 'timestamp': int(time.time()),
243
+ 'nonce': make_nonce()
244
+ }
245
+ data = dict()
246
+ if update_daily_budget_spec:
247
+ data["update_daily_budget_spec"] = update_daily_budget_spec
248
+ else:
249
+ data["update_daily_budget_spec"] = [
250
+ {
251
+ "account_id": account_id,
252
+ "daily_budget": daily_budget
253
+ }
254
+ ]
255
+ return lazyrequests.lazy_requests(
256
+ method="POST",
257
+ url=url,
258
+ params=params,
259
+ json=data
260
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lazyad
3
- Version: 0.0.37
3
+ Version: 0.0.40
4
4
  Summary: 基于Python的懒人包-适用于广告投放模块
5
5
  Home-page: https://gitee.com/ZeroSeeker/lazyad
6
6
  Author: ZeroSeeker
@@ -23,7 +23,17 @@ Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN
23
23
 
24
24
  #### 安装教程
25
25
 
26
- 1. xxxx
26
+ 1. 使用pip安装
27
+ - 普通方式安装
28
+ ```shell script
29
+ pip3 install lazyad
30
+ ```
31
+
32
+ - 使用阿里镜像加速安装
33
+ ```shell script
34
+ pip3 install lazyad -i https://mirrors.aliyun.com/pypi/simple
35
+ ```
36
+
27
37
  2. xxxx
28
38
  3. xxxx
29
39
 
@@ -0,0 +1,12 @@
1
+ lazyad/__init__.py,sha256=tnVTFEgdzgMWQI0mZqy3DAueMJjpypPb15DdxJ-9TiU,41
2
+ lazyad/crawlers/__init__.py,sha256=GK3GGpiUJbESc1uGTwSmEnsSUwYDNZfJCxeLYB4CpS4,68
3
+ lazyad/crawlers/chuangliang.py,sha256=nU57GkUGAXcu8TquqB9hg8Ysvl5E3ZlGX6pedj_nIwo,24830
4
+ lazyad/crawlers/mintegral.py,sha256=4wc_BipbWbdph0SWbNwkAfUlOnb05P0Z4RxqQGnnb8Q,5237
5
+ lazyad/crawlers/oceanengine.py,sha256=kjBEpCb_h5OpodCTqzvXd5MBBwAuw3Oq5UKWoTCXrQM,4540
6
+ lazyad/crawlers/qq.py,sha256=X_VjdgzAcDfckEAHrvdqBLtnmAuCBHPJVWu2H-IHZBA,5649
7
+ lazyad/open/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ lazyad/open/qq.py,sha256=pru1p4LCjURD9N5ukx-OStYAmDCvrTW4VMB2N0-3i5Q,6904
9
+ lazyad-0.0.40.dist-info/METADATA,sha256=GqFKB8Krwj6qupE00TQE0tBJftKP8Npq0VJkuUxp92E,1884
10
+ lazyad-0.0.40.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
11
+ lazyad-0.0.40.dist-info/top_level.txt,sha256=RAPjtj4gZYpsKAM3fAQrWyyn84xjdRuaiUS76gx6eNs,7
12
+ lazyad-0.0.40.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- lazyad/__init__.py,sha256=tnVTFEgdzgMWQI0mZqy3DAueMJjpypPb15DdxJ-9TiU,41
2
- lazyad/crawlers/__init__.py,sha256=GK3GGpiUJbESc1uGTwSmEnsSUwYDNZfJCxeLYB4CpS4,68
3
- lazyad/crawlers/chuangliang.py,sha256=nU57GkUGAXcu8TquqB9hg8Ysvl5E3ZlGX6pedj_nIwo,24830
4
- lazyad/crawlers/oceanengine.py,sha256=kjBEpCb_h5OpodCTqzvXd5MBBwAuw3Oq5UKWoTCXrQM,4540
5
- lazyad/crawlers/qq.py,sha256=mAVOP1TOGVD1juu77uKBauN7vLymukTJ1mJ8uyRh9a8,3230
6
- lazyad/open/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- lazyad/open/qq.py,sha256=B6HWnBmtF3mbpwto1wqi7j-auK73Kzp8ESxeUpvLHRA,4391
8
- lazyad-0.0.37.dist-info/METADATA,sha256=gkA-G3Sd5Bn_IJ6rWSkd0PNUqPLvl41-bCYtVrHswIE,1695
9
- lazyad-0.0.37.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
10
- lazyad-0.0.37.dist-info/top_level.txt,sha256=RAPjtj4gZYpsKAM3fAQrWyyn84xjdRuaiUS76gx6eNs,7
11
- lazyad-0.0.37.dist-info/RECORD,,