ayugespidertools 3.9.2__tar.gz → 3.9.3__tar.gz
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.
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/PKG-INFO +1 -1
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/__init__.py +1 -1
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/common/expend.py +2 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/common/multiplexing.py +0 -1
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/common/spiderconf.py +320 -313
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/extras/cvnpil.py +1 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/postgres/__init__.py +0 -1
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/postgres/asynced.py +10 -3
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/pyproject.toml +1 -1
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/LICENSE +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/README.md +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/commands/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/commands/crawl.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/commands/genspider.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/commands/startproject.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/commands/version.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/common/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/common/encryption.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/common/mongodbpipe.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/common/mysqlerrhandle.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/common/params.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/common/postgreserrhandle.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/common/sqlformat.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/common/typevars.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/common/utils.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/config.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/extras/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/extras/ext.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/formatdata.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/items.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/middlewares.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/mongoclient.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/mysqlclient.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/pipelines.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/request.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/http/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/http/request/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/http/request/form.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/middlewares/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/middlewares/headers/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/middlewares/headers/ua.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/middlewares/netlib/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/middlewares/netlib/aiohttplib.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/middlewares/proxy/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/middlewares/proxy/dynamic.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/middlewares/proxy/exclusive.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/download/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/download/file.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/mongo/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/mongo/asynced.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/mongo/fantasy.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/mongo/twisted.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/msgproducer/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/msgproducer/kafkapub.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/msgproducer/mqpub.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/mysql/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/mysql/asynced.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/mysql/fantasy.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/mysql/stats.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/mysql/turbo.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/mysql/twisted.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/oracle/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/oracle/fantasy.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/oracle/twisted.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/postgres/fantasy.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/postgres/twisted.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/spiders/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/spiders/crawl.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/spiders.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/project/README.md +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/project/module/VIT/.conf +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/project/module/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/project/module/items.py.tmpl +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/project/module/middlewares.py.tmpl +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/project/module/pipelines.py.tmpl +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/project/module/run.py.tmpl +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/project/module/run.sh.tmpl +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/project/module/settings.py.tmpl +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/project/module/spiders/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/project/pyproject.toml +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/project/requirements.txt +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/project/scrapy.cfg +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/spiders/async.tmpl +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/spiders/basic.tmpl +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/spiders/crawl.tmpl +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/spiders/csvfeed.tmpl +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/spiders/xmlfeed.tmpl +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/utils/__init__.py +0 -0
- {ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/utils/cmdline.py +0 -0
|
@@ -1,313 +1,320 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
from typing import TYPE_CHECKING, Generic, Optional, Tuple, TypeVar
|
|
3
|
-
|
|
4
|
-
from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
from ayugespidertools.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
@abstractmethod
|
|
59
|
-
def
|
|
60
|
-
self,
|
|
61
|
-
) ->
|
|
62
|
-
"""
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
) ->
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
#
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
)
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
def
|
|
308
|
-
creator: Creator,
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import TYPE_CHECKING, Generic, Optional, Tuple, TypeVar
|
|
3
|
+
|
|
4
|
+
from sqlalchemy.exc import OperationalError
|
|
5
|
+
|
|
6
|
+
from ayugespidertools.common.typevars import (
|
|
7
|
+
DatabaseEngineClass,
|
|
8
|
+
DynamicProxyConf,
|
|
9
|
+
ExclusiveProxyConf,
|
|
10
|
+
KafkaConf,
|
|
11
|
+
MongoDBConf,
|
|
12
|
+
MQConf,
|
|
13
|
+
MysqlConf,
|
|
14
|
+
OracleConf,
|
|
15
|
+
PostgreSQLConf,
|
|
16
|
+
)
|
|
17
|
+
from ayugespidertools.common.utils import ToolsForAyu
|
|
18
|
+
from ayugespidertools.config import logger
|
|
19
|
+
|
|
20
|
+
try:
|
|
21
|
+
from oracledb.exceptions import DatabaseError
|
|
22
|
+
except ImportError:
|
|
23
|
+
# pip install ayugespidertools[database]
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
"get_spider_conf",
|
|
28
|
+
"MysqlConfCreator",
|
|
29
|
+
"MongoDBConfCreator",
|
|
30
|
+
"MQConfCreator",
|
|
31
|
+
"OracleConfCreator",
|
|
32
|
+
"PostgreSQLConfCreator",
|
|
33
|
+
"KafkaConfCreator",
|
|
34
|
+
"DynamicProxyCreator",
|
|
35
|
+
"ExclusiveProxyCreator",
|
|
36
|
+
"get_sqlalchemy_conf",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
if TYPE_CHECKING:
|
|
40
|
+
from scrapy.settings import Settings
|
|
41
|
+
from sqlalchemy.engine.base import Connection as SqlalchemyConnectT
|
|
42
|
+
from sqlalchemy.engine.base import Engine as SqlalchemyEngineT
|
|
43
|
+
|
|
44
|
+
SpiderConf = TypeVar(
|
|
45
|
+
"SpiderConf",
|
|
46
|
+
MysqlConf,
|
|
47
|
+
MongoDBConf,
|
|
48
|
+
MQConf,
|
|
49
|
+
KafkaConf,
|
|
50
|
+
DynamicProxyConf,
|
|
51
|
+
ExclusiveProxyConf,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class Product(ABC, Generic[SpiderConf]):
|
|
58
|
+
@abstractmethod
|
|
59
|
+
def get_conn_conf(
|
|
60
|
+
self, settings: "Settings", remote_option: dict
|
|
61
|
+
) -> Optional[SpiderConf]:
|
|
62
|
+
"""获取各个工具链接配置信息"""
|
|
63
|
+
pass
|
|
64
|
+
|
|
65
|
+
@abstractmethod
|
|
66
|
+
def get_engine(
|
|
67
|
+
self, db_conf: SpiderConf, db_engine_enabled: bool
|
|
68
|
+
) -> Tuple[Optional["SqlalchemyEngineT"], Optional["SqlalchemyConnectT"]]:
|
|
69
|
+
"""获取各个工具中对应的 sqlalchemy db_engine 和 db_engine_conn。
|
|
70
|
+
需要此方法的工具有 mysql,postgresql,mongodb,oracle,其余的不需要。
|
|
71
|
+
"""
|
|
72
|
+
pass
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class Creator(ABC):
|
|
76
|
+
@abstractmethod
|
|
77
|
+
def create_product(self) -> Product:
|
|
78
|
+
pass
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class MysqlConfProduct(Product):
|
|
82
|
+
def get_conn_conf(
|
|
83
|
+
self, settings: "Settings", remote_option: dict
|
|
84
|
+
) -> Optional[MysqlConf]:
|
|
85
|
+
# 1). 优先从远程配置中取值
|
|
86
|
+
if settings.get("APP_CONF_MANAGE", False):
|
|
87
|
+
remote_conf = ToolsForAyu.fetch_remote_conf(
|
|
88
|
+
conf_name="mysql", **remote_option
|
|
89
|
+
)
|
|
90
|
+
return MysqlConf(**remote_conf) if remote_conf else None
|
|
91
|
+
|
|
92
|
+
# 2). 从本地参数中取值
|
|
93
|
+
local_conf = settings.get("MYSQL_CONFIG")
|
|
94
|
+
return MysqlConf(**local_conf) if local_conf else None
|
|
95
|
+
|
|
96
|
+
def get_engine(
|
|
97
|
+
self, db_conf: MysqlConf, db_engine_enabled: bool
|
|
98
|
+
) -> Tuple[Optional["SqlalchemyEngineT"], Optional["SqlalchemyConnectT"]]:
|
|
99
|
+
mysql_engine = mysql_engine_conn = None
|
|
100
|
+
if db_engine_enabled:
|
|
101
|
+
mysql_url = (
|
|
102
|
+
f"mysql+pymysql://{db_conf.user}"
|
|
103
|
+
f":{db_conf.password}@{db_conf.host}"
|
|
104
|
+
f":{db_conf.port}/{db_conf.database}"
|
|
105
|
+
f"?charset={db_conf.charset}"
|
|
106
|
+
)
|
|
107
|
+
try:
|
|
108
|
+
mysql_engine = DatabaseEngineClass(engine_url=mysql_url).engine
|
|
109
|
+
mysql_engine_conn = mysql_engine.connect()
|
|
110
|
+
except OperationalError as err:
|
|
111
|
+
logger.warning(f"MySQL engine enabled failed: {err}")
|
|
112
|
+
return mysql_engine, mysql_engine_conn
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class MongoDBConfProduct(Product):
|
|
116
|
+
def get_conn_conf(
|
|
117
|
+
self, settings: "Settings", remote_option: dict
|
|
118
|
+
) -> Optional[MongoDBConf]:
|
|
119
|
+
if settings.get("APP_CONF_MANAGE", False):
|
|
120
|
+
remote_conf = ToolsForAyu.fetch_remote_conf(
|
|
121
|
+
conf_name="mongodb", **remote_option
|
|
122
|
+
)
|
|
123
|
+
return MongoDBConf(**remote_conf) if remote_conf else None
|
|
124
|
+
|
|
125
|
+
local_conf = settings.get("MONGODB_CONFIG")
|
|
126
|
+
return MongoDBConf(**local_conf) if local_conf else None
|
|
127
|
+
|
|
128
|
+
def get_engine(self, db_conf: MongoDBConf, db_engine_enabled: bool):
|
|
129
|
+
pass
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class PostgreSQLConfProduct(Product):
|
|
133
|
+
def get_conn_conf(
|
|
134
|
+
self, settings: "Settings", remote_option: dict
|
|
135
|
+
) -> Optional[PostgreSQLConf]:
|
|
136
|
+
if settings.get("APP_CONF_MANAGE", False):
|
|
137
|
+
remote_conf = ToolsForAyu.fetch_remote_conf(
|
|
138
|
+
conf_name="postgresql", **remote_option
|
|
139
|
+
)
|
|
140
|
+
return PostgreSQLConf(**remote_conf) if remote_conf else None
|
|
141
|
+
|
|
142
|
+
local_conf = settings.get("POSTGRESQL_CONFIG")
|
|
143
|
+
return PostgreSQLConf(**local_conf) if local_conf else None
|
|
144
|
+
|
|
145
|
+
def get_engine(
|
|
146
|
+
self, db_conf: PostgreSQLConf, db_engine_enabled: bool
|
|
147
|
+
) -> Tuple[Optional["SqlalchemyEngineT"], Optional["SqlalchemyConnectT"]]:
|
|
148
|
+
postgres_engine = postgres_engine_conn = None
|
|
149
|
+
if db_engine_enabled:
|
|
150
|
+
postgres_url = (
|
|
151
|
+
f"postgresql+psycopg://{db_conf.user}:{db_conf.password}"
|
|
152
|
+
f"@{db_conf.host}:{db_conf.port}/{db_conf.database}"
|
|
153
|
+
)
|
|
154
|
+
try:
|
|
155
|
+
postgres_engine = DatabaseEngineClass(engine_url=postgres_url).engine
|
|
156
|
+
postgres_engine_conn = postgres_engine.connect()
|
|
157
|
+
except OperationalError as err:
|
|
158
|
+
logger.warning(f"PostgreSQL engine enabled failed: {err}")
|
|
159
|
+
return postgres_engine, postgres_engine_conn
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class OracleConfProduct(Product):
|
|
163
|
+
def get_conn_conf(
|
|
164
|
+
self, settings: "Settings", remote_option: dict
|
|
165
|
+
) -> Optional[OracleConf]:
|
|
166
|
+
if settings.get("APP_CONF_MANAGE", False):
|
|
167
|
+
remote_conf = ToolsForAyu.fetch_remote_conf(
|
|
168
|
+
conf_name="oracle", **remote_option
|
|
169
|
+
)
|
|
170
|
+
return OracleConf(**remote_conf) if remote_conf else None
|
|
171
|
+
|
|
172
|
+
local_conf = settings.get("ORACLE_CONFIG")
|
|
173
|
+
return OracleConf(**local_conf) if local_conf else None
|
|
174
|
+
|
|
175
|
+
def get_engine(
|
|
176
|
+
self, db_conf: OracleConf, db_engine_enabled: bool
|
|
177
|
+
) -> Tuple[Optional["SqlalchemyEngineT"], Optional["SqlalchemyConnectT"]]:
|
|
178
|
+
oracle_engine = oracle_engine_conn = None
|
|
179
|
+
if db_engine_enabled:
|
|
180
|
+
oracle_url = (
|
|
181
|
+
f"oracle+oracledb://{db_conf.user}:{db_conf.password}"
|
|
182
|
+
f"@{db_conf.host}:{db_conf.port}/{db_conf.service_name}"
|
|
183
|
+
)
|
|
184
|
+
thick_mode = (
|
|
185
|
+
{"lib_dir": db_conf.thick_lib_dir} if db_conf.thick_lib_dir else False
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
try:
|
|
189
|
+
oracle_engine = DatabaseEngineClass(
|
|
190
|
+
engine_url=oracle_url,
|
|
191
|
+
thick_mode=thick_mode,
|
|
192
|
+
).engine
|
|
193
|
+
oracle_engine_conn = oracle_engine.connect()
|
|
194
|
+
except (OperationalError, DatabaseError) as err:
|
|
195
|
+
logger.warning(f"Oracle engine enabled failed: {err}")
|
|
196
|
+
return oracle_engine, oracle_engine_conn
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
class MQConfProduct(Product):
|
|
200
|
+
def get_conn_conf(
|
|
201
|
+
self, settings: "Settings", remote_option: dict
|
|
202
|
+
) -> Optional[MQConf]:
|
|
203
|
+
if settings.get("APP_CONF_MANAGE", False):
|
|
204
|
+
remote_conf = ToolsForAyu.fetch_remote_conf(
|
|
205
|
+
conf_name="rabbitmq", **remote_option
|
|
206
|
+
)
|
|
207
|
+
return MQConf(**remote_conf) if remote_conf else None
|
|
208
|
+
|
|
209
|
+
local_conf = settings.get("MQ_CONFIG")
|
|
210
|
+
return MQConf(**local_conf) if local_conf else None
|
|
211
|
+
|
|
212
|
+
def get_engine(self, db_conf: MQConf, db_engine_enabled: bool):
|
|
213
|
+
pass
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
class KafkaConfProduct(Product):
|
|
217
|
+
def get_conn_conf(
|
|
218
|
+
self, settings: "Settings", remote_option: dict
|
|
219
|
+
) -> Optional[KafkaConf]:
|
|
220
|
+
if settings.get("APP_CONF_MANAGE", False):
|
|
221
|
+
remote_conf = ToolsForAyu.fetch_remote_conf(
|
|
222
|
+
conf_name="kafka", **remote_option
|
|
223
|
+
)
|
|
224
|
+
return KafkaConf(**remote_conf) if remote_conf else None
|
|
225
|
+
|
|
226
|
+
local_conf = settings.get("KAFKA_CONFIG")
|
|
227
|
+
return KafkaConf(**local_conf) if local_conf else None
|
|
228
|
+
|
|
229
|
+
def get_engine(self, db_conf: KafkaConf, db_engine_enabled: bool):
|
|
230
|
+
pass
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
class DynamicProxyProduct(Product):
|
|
234
|
+
def get_conn_conf(
|
|
235
|
+
self, settings: "Settings", remote_option: dict
|
|
236
|
+
) -> Optional[DynamicProxyConf]:
|
|
237
|
+
if settings.get("APP_CONF_MANAGE", False):
|
|
238
|
+
remote_conf = ToolsForAyu.fetch_remote_conf(
|
|
239
|
+
conf_name="dynamicproxy", **remote_option
|
|
240
|
+
)
|
|
241
|
+
return DynamicProxyConf(**remote_conf) if remote_conf else None
|
|
242
|
+
|
|
243
|
+
local_conf = settings.get("DYNAMIC_PROXY_CONFIG")
|
|
244
|
+
return DynamicProxyConf(**local_conf) if local_conf else None
|
|
245
|
+
|
|
246
|
+
def get_engine(self, db_conf: DynamicProxyConf, db_engine_enabled: bool):
|
|
247
|
+
pass
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
class ExclusiveProxyProduct(Product):
|
|
251
|
+
def get_conn_conf(
|
|
252
|
+
self, settings: "Settings", remote_option: dict
|
|
253
|
+
) -> Optional[ExclusiveProxyConf]:
|
|
254
|
+
if settings.get("APP_CONF_MANAGE", False):
|
|
255
|
+
remote_conf = ToolsForAyu.fetch_remote_conf(
|
|
256
|
+
conf_name="exclusiveproxy", **remote_option
|
|
257
|
+
)
|
|
258
|
+
return ExclusiveProxyConf(**remote_conf) if remote_conf else None
|
|
259
|
+
|
|
260
|
+
local_conf = settings.get("EXCLUSIVE_PROXY_CONFIG")
|
|
261
|
+
return ExclusiveProxyConf(**local_conf) if local_conf else None
|
|
262
|
+
|
|
263
|
+
def get_engine(self, db_conf: ExclusiveProxyConf, db_engine_enabled: bool):
|
|
264
|
+
pass
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
class MysqlConfCreator(Creator):
|
|
268
|
+
def create_product(self) -> Product:
|
|
269
|
+
return MysqlConfProduct()
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
class MongoDBConfCreator(Creator):
|
|
273
|
+
def create_product(self) -> Product:
|
|
274
|
+
return MongoDBConfProduct()
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
class PostgreSQLConfCreator(Creator):
|
|
278
|
+
def create_product(self) -> Product:
|
|
279
|
+
return PostgreSQLConfProduct()
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
class OracleConfCreator(Creator):
|
|
283
|
+
def create_product(self) -> Product:
|
|
284
|
+
return OracleConfProduct()
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
class MQConfCreator(Creator):
|
|
288
|
+
def create_product(self) -> Product:
|
|
289
|
+
return MQConfProduct()
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
class KafkaConfCreator(Creator):
|
|
293
|
+
def create_product(self) -> Product:
|
|
294
|
+
return KafkaConfProduct()
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
class DynamicProxyCreator(Creator):
|
|
298
|
+
def create_product(self) -> Product:
|
|
299
|
+
return DynamicProxyProduct()
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
class ExclusiveProxyCreator(Creator):
|
|
303
|
+
def create_product(self) -> Product:
|
|
304
|
+
return ExclusiveProxyProduct()
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
def get_spider_conf(
|
|
308
|
+
creator: Creator, settings: "Settings", remote_option: dict
|
|
309
|
+
) -> Optional[SpiderConf]:
|
|
310
|
+
product = creator.create_product()
|
|
311
|
+
return product.get_conn_conf(settings, remote_option)
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
def get_sqlalchemy_conf(
|
|
315
|
+
creator: Creator,
|
|
316
|
+
db_conf: SpiderConf,
|
|
317
|
+
db_engine_enabled: bool,
|
|
318
|
+
) -> Tuple[Optional["SqlalchemyEngineT"], Optional["SqlalchemyConnectT"]]:
|
|
319
|
+
product = creator.create_product()
|
|
320
|
+
return product.get_engine(db_conf, db_engine_enabled)
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
from typing import TYPE_CHECKING, Optional
|
|
2
2
|
|
|
3
|
-
from psycopg_pool import AsyncConnectionPool
|
|
4
3
|
from scrapy.utils.defer import deferred_from_coro
|
|
5
4
|
|
|
6
5
|
from ayugespidertools.common.expend import PostgreSQLPipeEnhanceMixin
|
|
7
6
|
from ayugespidertools.common.multiplexing import ReuseOperation
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
from
|
|
8
|
+
try:
|
|
9
|
+
from psycopg_pool import AsyncConnectionPool
|
|
10
|
+
except ImportError:
|
|
11
|
+
# pip install ayugespidertools[database]
|
|
12
|
+
pass
|
|
11
13
|
|
|
12
14
|
__all__ = [
|
|
13
15
|
"AyuAsyncPostgresPipeline",
|
|
14
16
|
]
|
|
15
17
|
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
from ayugespidertools.common.typevars import PostgreSQLConf
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
16
23
|
|
|
17
24
|
class AyuAsyncPostgresPipeline(PostgreSQLPipeEnhanceMixin):
|
|
18
25
|
"""postgresql asyncio 版本"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/common/postgreserrhandle.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/http/request/__init__.py
RENAMED
|
File without changes
|
{ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/http/request/form.py
RENAMED
|
File without changes
|
{ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/middlewares/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/middlewares/headers/ua.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/mysql/stats.py
RENAMED
|
File without changes
|
{ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/pipelines/mysql/turbo.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/scraper/spiders/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/project/README.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/project/pyproject.toml
RENAMED
|
File without changes
|
|
File without changes
|
{ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/project/scrapy.cfg
RENAMED
|
File without changes
|
{ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/spiders/async.tmpl
RENAMED
|
File without changes
|
{ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/spiders/basic.tmpl
RENAMED
|
File without changes
|
{ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/spiders/crawl.tmpl
RENAMED
|
File without changes
|
{ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/spiders/csvfeed.tmpl
RENAMED
|
File without changes
|
{ayugespidertools-3.9.2 → ayugespidertools-3.9.3}/ayugespidertools/templates/spiders/xmlfeed.tmpl
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|