lazyad 0.0.6__py3-none-any.whl → 0.0.8__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 CHANGED
@@ -1 +1,2 @@
1
1
  from . import crawlers
2
+ from . import open
File without changes
lazyad/open/qq.py ADDED
@@ -0,0 +1,112 @@
1
+ import time
2
+ import random
3
+ import json
4
+ from lazysdk import lazyrequests
5
+
6
+ """
7
+ 2024-04-11 全面升级至3.0版本 https://developers.e.qq.com/v3.0/docs/api
8
+ """
9
+
10
+
11
+ def make_nonce():
12
+ """
13
+ 参考示例代码的生成一个随机数
14
+ :return:
15
+ """
16
+ return str(time.time()) + str(random.randint(0, 999999))
17
+
18
+
19
+ def oauth_token2(
20
+ app_id,
21
+ app_secret,
22
+ redirect_uri,
23
+ grant_type='authorization_code',
24
+ auth_code=None,
25
+ refresh_token=None,
26
+ ):
27
+ """
28
+ OAuth 2.0 授权
29
+ 获取/刷新token
30
+ 相关文档:https://developers.e.qq.com/docs/start/authorization
31
+ :param auth_code:
32
+ :param app_id:
33
+ :param app_secret:
34
+ :param grant_type: 请求的类型,可选值:authorization_code(授权码方式获取 token)、refresh_token(刷新 token)
35
+ :param refresh_token:
36
+ :param redirect_uri:
37
+ :return:
38
+ """
39
+ redirect_uri = f'{redirect_uri}?app_id={app_id}'
40
+
41
+ url = 'https://api.e.qq.com/oauth/token'
42
+ params = {
43
+ 'client_id': app_id,
44
+ 'client_secret': app_secret,
45
+ 'grant_type': grant_type
46
+ }
47
+ if auth_code:
48
+ params['authorization_code'] = auth_code
49
+ if refresh_token:
50
+ params['refresh_token'] = refresh_token
51
+ if redirect_uri:
52
+ params['redirect_uri'] = redirect_uri
53
+
54
+ for k in params:
55
+ if type(params[k]) is not str:
56
+ params[k] = json.dumps(params[k])
57
+
58
+ return lazyrequests.lazy_requests(
59
+ method="GET",
60
+ url=url,
61
+ params=params
62
+ )
63
+
64
+
65
+ def oauth_token3(
66
+ access_token,
67
+ app_id,
68
+ app_secret,
69
+ redirect_uri,
70
+ grant_type='authorization_code',
71
+ auth_code=None,
72
+ refresh_token=None,
73
+ ):
74
+ """
75
+ 获取/刷新token
76
+ 相关文档:https://developers.e.qq.com/v3.0/docs/api/oauth/token
77
+ :param access_token:
78
+ :param auth_code:
79
+ :param app_id:
80
+ :param app_secret:
81
+ :param grant_type: 请求的类型,可选值:authorization_code(授权码方式获取 token)、refresh_token(刷新 token)
82
+ :param refresh_token:
83
+ :param redirect_uri: 回调地址
84
+ :return:
85
+ """
86
+ redirect_uri = f'{redirect_uri}?app_id={app_id}'
87
+ url = 'https://api.e.qq.com/v3.0/oauth/token'
88
+ params = {
89
+ 'access_token': access_token,
90
+ 'timestamp': int(time.time()),
91
+ 'nonce': make_nonce,
92
+
93
+ 'client_id': app_id,
94
+ 'client_secret': app_secret,
95
+ 'grant_type': grant_type
96
+ }
97
+ if auth_code:
98
+ params['authorization_code'] = auth_code
99
+ if refresh_token:
100
+ params['refresh_token'] = refresh_token
101
+ if redirect_uri:
102
+ params['redirect_uri'] = redirect_uri
103
+
104
+ for k in params:
105
+ if type(params[k]) is not str:
106
+ params[k] = json.dumps(params[k])
107
+
108
+ return lazyrequests.lazy_requests(
109
+ method="GET",
110
+ url=url,
111
+ params=params
112
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lazyad
3
- Version: 0.0.6
3
+ Version: 0.0.8
4
4
  Summary: 基于Python的懒人包-适用于广告投放模块
5
5
  Home-page: https://gitee.com/ZeroSeeker/lazyad
6
6
  Author: ZeroSeeker
@@ -0,0 +1,11 @@
1
+ lazyad/__init__.py,sha256=tnVTFEgdzgMWQI0mZqy3DAueMJjpypPb15DdxJ-9TiU,41
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/open/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ lazyad/open/qq.py,sha256=0bxNsUF8I8xgkujZ2ni1UYzeBC4ATcGC2azNJHL4oWQ,2886
8
+ lazyad-0.0.8.dist-info/METADATA,sha256=VnnUKrCnmLsONjrLJFx89DwMZBjvoWpi4B08o3BugjA,1694
9
+ lazyad-0.0.8.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
10
+ lazyad-0.0.8.dist-info/top_level.txt,sha256=RAPjtj4gZYpsKAM3fAQrWyyn84xjdRuaiUS76gx6eNs,7
11
+ lazyad-0.0.8.dist-info/RECORD,,
@@ -1,9 +0,0 @@
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,,
File without changes