lazyad 0.0.6__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.

lazyad/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from . import crawlers
@@ -0,0 +1,3 @@
1
+ from . import qq
2
+ from . import oceanengine
3
+ from . import chuangliang
@@ -0,0 +1,54 @@
1
+ from lazysdk import lazyrequests
2
+ import copy
3
+
4
+ default_headers = {
5
+ "Accept": "application/json, text/plain, */*",
6
+ "Accept-Encoding": "gzip, deflate",
7
+ "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",
8
+ "Connection": "keep-alive",
9
+ "Host": "cli2.mobgi.com",
10
+ "Origin": "https://cl.mobgi.com",
11
+ "Referer": "https://cl.mobgi.com/",
12
+ "Sec-Fetch-Dest": "empty",
13
+ "Sec-Fetch-Mode": "cors",
14
+ "Sec-Fetch-Site": "same-site",
15
+ "TE": "trailers",
16
+ "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:105.0) Gecko/20100101 Firefox/105.0",
17
+ }
18
+
19
+
20
+ def get_media_account(
21
+ media_type: str,
22
+ cookie: str = None,
23
+ page: int = 1,
24
+ page_size: int = 20,
25
+ total_count: int = 0
26
+ ):
27
+ """
28
+ 获取 推广-账户管理下的账户列表
29
+ :param media_type: 媒体类型
30
+ :param cookie:
31
+ :param page:
32
+ :param page_size:
33
+ :param total_count:
34
+ :return:
35
+ """
36
+
37
+ url = 'https://cli2.mobgi.com/Media/Account/getList'
38
+ data = {
39
+ "media_type": media_type,
40
+ "advertiser_type": "1",
41
+ "page": page,
42
+ "page_size": page_size,
43
+ "total_count": total_count
44
+ }
45
+ headers = copy.deepcopy(default_headers)
46
+ headers["Cookie"] = cookie
47
+
48
+ return lazyrequests.lazy_requests(
49
+ method='POST',
50
+ url=url,
51
+ json=data,
52
+ headers=headers,
53
+ return_json=True
54
+ )
@@ -0,0 +1,155 @@
1
+ from lazysdk import lazyrequests
2
+ from lazysdk import lazytime
3
+ from urllib import parse
4
+ import copy
5
+ import re
6
+
7
+
8
+ default_headers = {
9
+ "Accept": "application/json, text/plain, */*",
10
+ "Accept-Encoding": "gzip, deflate",
11
+ "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",
12
+ "Connection": "keep-alive",
13
+ "Content-Type": "application/json",
14
+ "Host": "business.oceanengine.com",
15
+ "Origin": "https://business.oceanengine.com",
16
+ "Sec-Fetch-Dest": "empty",
17
+ "Sec-Fetch-Mode": "cors",
18
+ "Sec-Fetch-Site": "same-origin",
19
+ "TE": "trailers",
20
+ "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/115.0"
21
+ }
22
+ default_timeout = 10
23
+
24
+
25
+ def get_token_from_cookie(
26
+ cookie: str
27
+ ):
28
+ """
29
+ 从cookie中提取token
30
+ :param cookie:
31
+ :return:
32
+ """
33
+ cookie = parse.unquote(cookie.replace('+', '%20')) # 处理解码
34
+ find_csrf_token = re.findall(r'csrftoken=(.*?);', cookie, re.S)
35
+ if find_csrf_token:
36
+ csrf_token = find_csrf_token[0]
37
+ return csrf_token
38
+ else:
39
+ return None
40
+
41
+
42
+ def get_account_list(
43
+ cookie: str,
44
+ csrf_token: str = None,
45
+ page: int = 1,
46
+ page_size: int = 10,
47
+ timeout: int = default_timeout,
48
+ start_date: str = None,
49
+ end_date: str = None,
50
+ order_field: str = 'stat_cost',
51
+ order_type: int = 1
52
+ ):
53
+ """
54
+ 主账号获取账户列表信息
55
+ 【账户】-【巨量广告】-【升级版】-【账户】
56
+ :param cookie:
57
+ :param csrf_token:
58
+ :param page: 页码,默认为1
59
+ :param page_size: 每页数量,默认为10,可选10,20,50,100
60
+ :param timeout: 超时时间,单位为秒,默认为5
61
+ :param start_date: 开始日期,默认为当日0点,例如:2022-03-21
62
+ :param end_date: 结束日期,默认为次日0点,例如:2022-03-22
63
+ :param order_field: 排序列,默认为stat_cost,默认按照消耗排序
64
+ :param order_type: 排序方式:0:升序,1:降序;默认为1,降序
65
+ """
66
+ url = "https://business.oceanengine.com/nbs/api/bm/promotion/ad/get_account_list"
67
+ # ------------------ 标准过程 ------------------
68
+ if not csrf_token:
69
+ csrf_token = get_token_from_cookie(cookie=cookie)
70
+ temp_headers = copy.deepcopy(default_headers)
71
+ temp_headers["Cookie"] = cookie
72
+ if csrf_token:
73
+ temp_headers["x-csrftoken"] = csrf_token
74
+ # ------------------ 标准过程 ------------------
75
+
76
+ if start_date:
77
+ start_time = lazytime.get_date2timestamp(date=start_date)
78
+ else:
79
+ start_time = lazytime.get_date2timestamp(date=lazytime.get_date_string(-1))
80
+
81
+ if end_date:
82
+ end_time = lazytime.get_date2timestamp(date=end_date) + 86400
83
+ else:
84
+ end_time = lazytime.get_date2timestamp(date=lazytime.get_date_string(0))
85
+
86
+ data = {
87
+ "offset": page,
88
+ "limit": page_size,
89
+ "order_type": order_type,
90
+ "order_field": order_field,
91
+ "fields": [
92
+ "convert_cnt",
93
+ "conversion_cost",
94
+ "conversion_rate",
95
+ "deep_convert_cnt",
96
+ "deep_convert_cost",
97
+ "deep_convert_rate",
98
+ "stat_cost",
99
+ "show_cnt",
100
+ "cpm_platform",
101
+ "click_cnt",
102
+ "ctr",
103
+ "cpc_platform"
104
+ ],
105
+ "cascade_metrics": [
106
+ "advertiser_followed",
107
+ "advertiser_name",
108
+ "advertiser_id",
109
+ "advertiser_status",
110
+ "advertiser_budget",
111
+ "advertiser_remark", # 账户备注
112
+ "advertiser_balance",
113
+ "advertiser_valid_balance"
114
+ ],
115
+ "filter": {
116
+ "group": {
117
+
118
+ },
119
+ "advertiser": {
120
+
121
+ },
122
+ "campaign": {
123
+
124
+ },
125
+ "ad": {
126
+
127
+ },
128
+ "project": {
129
+
130
+ },
131
+ "promotion": {
132
+
133
+ },
134
+ "search": {
135
+ "keyword": "",
136
+ "searchType": 0,
137
+ "queryType": "phrase"
138
+ },
139
+ "pricingCategory": [
140
+ 2
141
+ ]
142
+ },
143
+ "account_type": 0,
144
+ "platform_version": "2.0",
145
+ "start_time": str(start_time),
146
+ "end_time": str(end_time)
147
+ }
148
+ return lazyrequests.lazy_requests(
149
+ method='POST',
150
+ url=url,
151
+ headers=temp_headers,
152
+ json=data,
153
+ timeout=timeout,
154
+ return_json=True
155
+ )
lazyad/crawlers/qq.py ADDED
@@ -0,0 +1,95 @@
1
+ from lazysdk import lazyrequests
2
+ from lazysdk import lazytime
3
+ import copy
4
+
5
+
6
+ default_headers = {
7
+ "Host": "ad.qq.com",
8
+ "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:123.0) Gecko/20100101 Firefox/123.0",
9
+ "Accept": "application/json, text/javascript, */*; q=0.01",
10
+ "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",
11
+ "Accept-Encoding": "gzip, deflate",
12
+ "Content-Type": "application/json",
13
+ "X-Requested-With": "XMLHttpRequest",
14
+ "Connection": "keep-alive",
15
+ "Sec-Fetch-Dest": "empty",
16
+ "Sec-Fetch-Mode": "cors",
17
+ "Sec-Fetch-Site": "same-origin",
18
+ "Pragma": "no-cache",
19
+ "Cache-Control": "no-cache",
20
+ "TE": "trailers"
21
+ } # 默认的header
22
+
23
+
24
+ def new_account_list(
25
+ cookie: str,
26
+ user_id: int,
27
+ business_id: int,
28
+ start_date: str = None,
29
+ end_date: str = None,
30
+ page: int = 1,
31
+ page_size: int = 20,
32
+ account_id: int = None, # 支持按户id搜索
33
+ account_status: int = 1
34
+ ):
35
+ """
36
+ 概览-账户 页面按照消耗降序排序的数据
37
+ :param cookie:
38
+ :param user_id: 登录用户的id
39
+ :param business_id: 大户id
40
+ :param start_date:
41
+ :param end_date:
42
+ :param page:
43
+ :param page_size:
44
+ :param account_id: 子户id
45
+ :param account_status: 账户状态
46
+ 1:有效
47
+ 2:待审核
48
+ 3:审核不通过
49
+ 4:封停
50
+ 21:临时冻结
51
+ :return:
52
+ """
53
+ if not start_date:
54
+ start_date = lazytime.get_date_string(days=-1)
55
+ if not end_date:
56
+ end_date = lazytime.get_date_string(days=-1)
57
+ url = "https://ad.qq.com/tap/v1/account_daily_report/new_account_list?unicode=1&post_format=json"
58
+ temp_headers = copy.deepcopy(default_headers)
59
+ temp_headers["Cookie"] = cookie
60
+ data = {
61
+ "new_source": 1,
62
+ "user_id": user_id,
63
+ "sort_seq": "desc", # 降序排序,会自动过滤0数据
64
+ "sort_field": "cost", # 按照消耗排序
65
+ "page": page,
66
+ "page_size": page_size,
67
+ "need_sync": True,
68
+ "sync_param_ready": True,
69
+ "business_id_list": [
70
+ business_id
71
+ ],
72
+ "dynamic_field_list": [
73
+ "corporation_name",
74
+ "corporation_alias",
75
+ "rule_target_enable",
76
+ "derive_status",
77
+ "comment", # 标签
78
+ "cost" # 消耗
79
+ ],
80
+ "time_line": "REQUEST_TIME",
81
+ "start_date_millons": lazytime.get_date2timestamp(date=start_date) * 1000, # 开始时间的时间戳
82
+ "end_date_millons": lazytime.get_date2timestamp(date=end_date) * 1000, # 结束时间的时间戳
83
+ "account_status": account_status,
84
+ "platform_type": 1,
85
+ "use_top_sort": True,
86
+ "filter_empty_data": 0
87
+ }
88
+ if account_id:
89
+ data["account_id"] = [account_id]
90
+ return lazyrequests.lazy_requests(
91
+ method="POST",
92
+ url=url,
93
+ headers=temp_headers,
94
+ json=data
95
+ )
@@ -0,0 +1,51 @@
1
+ Metadata-Version: 2.1
2
+ Name: lazyad
3
+ Version: 0.0.6
4
+ Summary: 基于Python的懒人包-适用于广告投放模块
5
+ Home-page: https://gitee.com/ZeroSeeker/lazyad
6
+ Author: ZeroSeeker
7
+ Author-email: zeroseeker@foxmail.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: lazysdk >=0.1.88
12
+
13
+ # lazyad
14
+
15
+ #### 介绍
16
+ {**以下是 Gitee 平台说明,您可以替换此简介**
17
+ Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台
18
+ 无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)}
19
+
20
+ #### 软件架构
21
+ 软件架构说明
22
+
23
+
24
+ #### 安装教程
25
+
26
+ 1. xxxx
27
+ 2. xxxx
28
+ 3. xxxx
29
+
30
+ #### 使用说明
31
+
32
+ 1. xxxx
33
+ 2. xxxx
34
+ 3. xxxx
35
+
36
+ #### 参与贡献
37
+
38
+ 1. Fork 本仓库
39
+ 2. 新建 Feat_xxx 分支
40
+ 3. 提交代码
41
+ 4. 新建 Pull Request
42
+
43
+
44
+ #### 特技
45
+
46
+ 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
47
+ 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
48
+ 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
49
+ 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
50
+ 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
51
+ 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
@@ -0,0 +1,9 @@
1
+ lazyad/__init__.py,sha256=ELZ9AH9-9Y32cf_jgHhvgEKGVOyKhRDCxHNLfiHB1sY,23
2
+ lazyad/crawlers/__init__.py,sha256=GK3GGpiUJbESc1uGTwSmEnsSUwYDNZfJCxeLYB4CpS4,68
3
+ lazyad/crawlers/chuangliang.py,sha256=mVlfN5fipQdRc6STuC0B68ntGCU23I1PF2sD5q2jncg,1482
4
+ lazyad/crawlers/oceanengine.py,sha256=kjBEpCb_h5OpodCTqzvXd5MBBwAuw3Oq5UKWoTCXrQM,4540
5
+ lazyad/crawlers/qq.py,sha256=5W5xVOmRtYRBhuFtrbX9XcrdmgeiV71zIIAtqF44io4,3060
6
+ lazyad-0.0.6.dist-info/METADATA,sha256=LZJV5_lthTjd-pnrGmaZs3aKQlkuinBvXoISUo8ULhI,1694
7
+ lazyad-0.0.6.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
8
+ lazyad-0.0.6.dist-info/top_level.txt,sha256=RAPjtj4gZYpsKAM3fAQrWyyn84xjdRuaiUS76gx6eNs,7
9
+ lazyad-0.0.6.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.41.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ lazyad