crawlo 1.2.0__py3-none-any.whl → 1.2.2__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 crawlo might be problematic. Click here for more details.
- crawlo/__init__.py +61 -61
- crawlo/__version__.py +1 -1
- crawlo/cleaners/__init__.py +60 -60
- crawlo/cleaners/data_formatter.py +225 -225
- crawlo/cleaners/encoding_converter.py +125 -125
- crawlo/cleaners/text_cleaner.py +232 -232
- crawlo/cli.py +81 -65
- crawlo/commands/__init__.py +14 -14
- crawlo/commands/check.py +594 -594
- crawlo/commands/genspider.py +151 -151
- crawlo/commands/help.py +143 -133
- crawlo/commands/list.py +155 -155
- crawlo/commands/run.py +292 -292
- crawlo/commands/startproject.py +418 -418
- crawlo/commands/stats.py +188 -188
- crawlo/commands/utils.py +186 -186
- crawlo/config.py +312 -312
- crawlo/config_validator.py +252 -252
- crawlo/core/__init__.py +2 -2
- crawlo/core/engine.py +354 -354
- crawlo/core/processor.py +40 -40
- crawlo/core/scheduler.py +143 -143
- crawlo/crawler.py +1027 -1027
- crawlo/downloader/__init__.py +266 -266
- crawlo/downloader/aiohttp_downloader.py +220 -220
- crawlo/downloader/cffi_downloader.py +256 -256
- crawlo/downloader/httpx_downloader.py +259 -259
- crawlo/downloader/hybrid_downloader.py +213 -213
- crawlo/downloader/playwright_downloader.py +402 -402
- crawlo/downloader/selenium_downloader.py +472 -472
- crawlo/event.py +11 -11
- crawlo/exceptions.py +81 -81
- crawlo/extension/__init__.py +37 -37
- crawlo/extension/health_check.py +141 -141
- crawlo/extension/log_interval.py +57 -57
- crawlo/extension/log_stats.py +81 -81
- crawlo/extension/logging_extension.py +43 -43
- crawlo/extension/memory_monitor.py +104 -104
- crawlo/extension/performance_profiler.py +133 -133
- crawlo/extension/request_recorder.py +107 -107
- crawlo/filters/__init__.py +154 -154
- crawlo/filters/aioredis_filter.py +280 -280
- crawlo/filters/memory_filter.py +269 -269
- crawlo/items/__init__.py +23 -23
- crawlo/items/base.py +21 -21
- crawlo/items/fields.py +53 -53
- crawlo/items/items.py +104 -104
- crawlo/middleware/__init__.py +21 -21
- crawlo/middleware/default_header.py +132 -32
- crawlo/middleware/download_delay.py +105 -28
- crawlo/middleware/middleware_manager.py +135 -135
- crawlo/middleware/offsite.py +116 -0
- crawlo/middleware/proxy.py +366 -272
- crawlo/middleware/request_ignore.py +88 -30
- crawlo/middleware/response_code.py +164 -18
- crawlo/middleware/response_filter.py +138 -26
- crawlo/middleware/retry.py +124 -124
- crawlo/mode_manager.py +211 -211
- crawlo/network/__init__.py +21 -21
- crawlo/network/request.py +338 -338
- crawlo/network/response.py +359 -359
- crawlo/pipelines/__init__.py +21 -21
- crawlo/pipelines/bloom_dedup_pipeline.py +156 -156
- crawlo/pipelines/console_pipeline.py +39 -39
- crawlo/pipelines/csv_pipeline.py +316 -316
- crawlo/pipelines/database_dedup_pipeline.py +224 -224
- crawlo/pipelines/json_pipeline.py +218 -218
- crawlo/pipelines/memory_dedup_pipeline.py +115 -115
- crawlo/pipelines/mongo_pipeline.py +131 -131
- crawlo/pipelines/mysql_pipeline.py +316 -316
- crawlo/pipelines/pipeline_manager.py +61 -61
- crawlo/pipelines/redis_dedup_pipeline.py +167 -167
- crawlo/project.py +187 -187
- crawlo/queue/pqueue.py +37 -37
- crawlo/queue/queue_manager.py +337 -337
- crawlo/queue/redis_priority_queue.py +298 -298
- crawlo/settings/__init__.py +7 -7
- crawlo/settings/default_settings.py +226 -219
- crawlo/settings/setting_manager.py +122 -122
- crawlo/spider/__init__.py +639 -639
- crawlo/stats_collector.py +59 -59
- crawlo/subscriber.py +130 -130
- crawlo/task_manager.py +30 -30
- crawlo/templates/crawlo.cfg.tmpl +10 -10
- crawlo/templates/project/__init__.py.tmpl +3 -3
- crawlo/templates/project/items.py.tmpl +17 -17
- crawlo/templates/project/middlewares.py.tmpl +118 -109
- crawlo/templates/project/pipelines.py.tmpl +96 -96
- crawlo/templates/project/run.py.tmpl +45 -45
- crawlo/templates/project/settings.py.tmpl +327 -326
- crawlo/templates/project/settings_distributed.py.tmpl +119 -119
- crawlo/templates/project/settings_gentle.py.tmpl +94 -94
- crawlo/templates/project/settings_high_performance.py.tmpl +151 -151
- crawlo/templates/project/settings_simple.py.tmpl +68 -68
- crawlo/templates/project/spiders/__init__.py.tmpl +5 -5
- crawlo/templates/spider/spider.py.tmpl +143 -141
- crawlo/tools/__init__.py +182 -182
- crawlo/tools/anti_crawler.py +268 -268
- crawlo/tools/authenticated_proxy.py +240 -240
- crawlo/tools/data_validator.py +180 -180
- crawlo/tools/date_tools.py +35 -35
- crawlo/tools/distributed_coordinator.py +386 -386
- crawlo/tools/retry_mechanism.py +220 -220
- crawlo/tools/scenario_adapter.py +262 -262
- crawlo/utils/__init__.py +35 -35
- crawlo/utils/batch_processor.py +260 -260
- crawlo/utils/controlled_spider_mixin.py +439 -439
- crawlo/utils/date_tools.py +290 -290
- crawlo/utils/db_helper.py +343 -343
- crawlo/utils/enhanced_error_handler.py +359 -359
- crawlo/utils/env_config.py +105 -105
- crawlo/utils/error_handler.py +125 -125
- crawlo/utils/func_tools.py +82 -82
- crawlo/utils/large_scale_config.py +286 -286
- crawlo/utils/large_scale_helper.py +343 -343
- crawlo/utils/log.py +128 -128
- crawlo/utils/performance_monitor.py +284 -284
- crawlo/utils/queue_helper.py +175 -175
- crawlo/utils/redis_connection_pool.py +334 -334
- crawlo/utils/redis_key_validator.py +199 -199
- crawlo/utils/request.py +267 -267
- crawlo/utils/request_serializer.py +219 -219
- crawlo/utils/spider_loader.py +62 -62
- crawlo/utils/system.py +11 -11
- crawlo/utils/tools.py +4 -4
- crawlo/utils/url.py +39 -39
- {crawlo-1.2.0.dist-info → crawlo-1.2.2.dist-info}/METADATA +692 -697
- crawlo-1.2.2.dist-info/RECORD +220 -0
- examples/__init__.py +7 -7
- examples/aiohttp_settings.py +42 -0
- examples/curl_cffi_settings.py +41 -0
- examples/default_header_middleware_example.py +107 -0
- examples/default_header_spider_example.py +129 -0
- examples/download_delay_middleware_example.py +160 -0
- examples/httpx_settings.py +42 -0
- examples/multi_downloader_proxy_example.py +81 -0
- examples/offsite_middleware_example.py +55 -0
- examples/offsite_spider_example.py +107 -0
- examples/proxy_spider_example.py +166 -0
- examples/request_ignore_middleware_example.py +51 -0
- examples/request_ignore_spider_example.py +99 -0
- examples/response_code_middleware_example.py +52 -0
- examples/response_filter_middleware_example.py +67 -0
- examples/tong_hua_shun_settings.py +62 -0
- examples/tong_hua_shun_spider.py +170 -0
- tests/DOUBLE_CRAWLO_PREFIX_FIX_REPORT.md +81 -81
- tests/__init__.py +7 -7
- tests/advanced_tools_example.py +275 -275
- tests/authenticated_proxy_example.py +236 -236
- tests/cleaners_example.py +160 -160
- tests/config_validation_demo.py +102 -102
- tests/controlled_spider_example.py +205 -205
- tests/date_tools_example.py +180 -180
- tests/dynamic_loading_example.py +523 -523
- tests/dynamic_loading_test.py +104 -104
- tests/env_config_example.py +133 -133
- tests/error_handling_example.py +171 -171
- tests/redis_key_validation_demo.py +130 -130
- tests/response_improvements_example.py +144 -144
- tests/test_advanced_tools.py +148 -148
- tests/test_all_redis_key_configs.py +145 -145
- tests/test_authenticated_proxy.py +141 -141
- tests/test_cleaners.py +54 -54
- tests/test_comprehensive.py +146 -146
- tests/test_config_validator.py +193 -193
- tests/test_crawlo_proxy_integration.py +173 -0
- tests/test_date_tools.py +123 -123
- tests/test_default_header_middleware.py +159 -0
- tests/test_double_crawlo_fix.py +207 -207
- tests/test_double_crawlo_fix_simple.py +124 -124
- tests/test_download_delay_middleware.py +222 -0
- tests/test_downloader_proxy_compatibility.py +269 -0
- tests/test_dynamic_downloaders_proxy.py +124 -124
- tests/test_dynamic_proxy.py +92 -92
- tests/test_dynamic_proxy_config.py +146 -146
- tests/test_dynamic_proxy_real.py +109 -109
- tests/test_edge_cases.py +303 -303
- tests/test_enhanced_error_handler.py +270 -270
- tests/test_env_config.py +121 -121
- tests/test_error_handler_compatibility.py +112 -112
- tests/test_final_validation.py +153 -153
- tests/test_framework_env_usage.py +103 -103
- tests/test_integration.py +356 -356
- tests/test_item_dedup_redis_key.py +122 -122
- tests/test_offsite_middleware.py +222 -0
- tests/test_parsel.py +29 -29
- tests/test_performance.py +327 -327
- tests/test_proxy_api.py +265 -0
- tests/test_proxy_health_check.py +32 -32
- tests/test_proxy_middleware.py +122 -0
- tests/test_proxy_middleware_enhanced.py +217 -0
- tests/test_proxy_middleware_integration.py +136 -136
- tests/test_proxy_providers.py +56 -56
- tests/test_proxy_stats.py +19 -19
- tests/test_proxy_strategies.py +59 -59
- tests/test_queue_manager_double_crawlo.py +173 -173
- tests/test_queue_manager_redis_key.py +176 -176
- tests/test_real_scenario_proxy.py +196 -0
- tests/test_redis_config.py +28 -28
- tests/test_redis_connection_pool.py +294 -294
- tests/test_redis_key_naming.py +181 -181
- tests/test_redis_key_validator.py +123 -123
- tests/test_redis_queue.py +224 -224
- tests/test_request_ignore_middleware.py +183 -0
- tests/test_request_serialization.py +70 -70
- tests/test_response_code_middleware.py +350 -0
- tests/test_response_filter_middleware.py +428 -0
- tests/test_response_improvements.py +152 -152
- tests/test_retry_middleware.py +242 -0
- tests/test_scheduler.py +241 -241
- tests/test_simple_response.py +61 -61
- tests/test_telecom_spider_redis_key.py +205 -205
- tests/test_template_content.py +87 -87
- tests/test_template_redis_key.py +134 -134
- tests/test_tools.py +153 -153
- tests/tools_example.py +257 -257
- crawlo-1.2.0.dist-info/RECORD +0 -190
- {crawlo-1.2.0.dist-info → crawlo-1.2.2.dist-info}/WHEEL +0 -0
- {crawlo-1.2.0.dist-info → crawlo-1.2.2.dist-info}/entry_points.txt +0 -0
- {crawlo-1.2.0.dist-info → crawlo-1.2.2.dist-info}/top_level.txt +0 -0
|
@@ -1,697 +1,692 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: crawlo
|
|
3
|
-
Version: 1.2.
|
|
4
|
-
Summary: Crawlo 是一款基于异步IO的高性能Python爬虫框架,支持分布式抓取。
|
|
5
|
-
Home-page: https://github.com/crawl-coder/Crawlo.git
|
|
6
|
-
Author: crawl-coder
|
|
7
|
-
Author-email: crawlo@qq.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Requires-Python: >=3.6
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
Requires-Dist: aiohttp>=3.12.14
|
|
15
|
-
Requires-Dist: aiomysql>=0.2.0
|
|
16
|
-
Requires-Dist: aioredis>=2.0.1
|
|
17
|
-
Requires-Dist: asyncmy>=0.2.10
|
|
18
|
-
Requires-Dist: cssselect>=1.2.0
|
|
19
|
-
Requires-Dist: dateparser>=1.2.2
|
|
20
|
-
Requires-Dist: httpx[http2]>=0.27.0
|
|
21
|
-
Requires-Dist: curl-cffi>=0.13.0
|
|
22
|
-
Requires-Dist: lxml>=5.2.1
|
|
23
|
-
Requires-Dist: motor>=3.7.0
|
|
24
|
-
Requires-Dist: parsel>=1.9.1
|
|
25
|
-
Requires-Dist: pydantic>=2.11.7
|
|
26
|
-
Requires-Dist: pymongo>=4.11
|
|
27
|
-
Requires-Dist: PyMySQL>=1.1.1
|
|
28
|
-
Requires-Dist: python-dateutil>=2.9.0.post0
|
|
29
|
-
Requires-Dist: redis>=6.2.0
|
|
30
|
-
Requires-Dist: requests>=2.32.4
|
|
31
|
-
Requires-Dist: six>=1.17.0
|
|
32
|
-
Requires-Dist: ujson>=5.9.0
|
|
33
|
-
Requires-Dist: urllib3>=2.5.0
|
|
34
|
-
Requires-Dist: w3lib>=2.1.2
|
|
35
|
-
Requires-Dist: rich>=14.1.0
|
|
36
|
-
Requires-Dist: astor>=0.8.1
|
|
37
|
-
Requires-Dist: watchdog>=6.0.0
|
|
38
|
-
Provides-Extra: render
|
|
39
|
-
Requires-Dist: webdriver-manager>=4.0.0; extra == "render"
|
|
40
|
-
Requires-Dist: playwright; extra == "render"
|
|
41
|
-
Requires-Dist: selenium>=3.141.0; extra == "render"
|
|
42
|
-
Provides-Extra: all
|
|
43
|
-
Requires-Dist: bitarray>=1.5.3; extra == "all"
|
|
44
|
-
Requires-Dist: PyExecJS>=1.5.1; extra == "all"
|
|
45
|
-
Requires-Dist: pymongo>=3.10.1; extra == "all"
|
|
46
|
-
Requires-Dist: redis-py-cluster>=2.1.0; extra == "all"
|
|
47
|
-
Requires-Dist: webdriver-manager>=4.0.0; extra == "all"
|
|
48
|
-
Requires-Dist: playwright; extra == "all"
|
|
49
|
-
Requires-Dist: selenium>=3.141.0; extra == "all"
|
|
50
|
-
|
|
51
|
-
<!-- markdownlint-disable MD033 MD041 -->
|
|
52
|
-
<div align="center">
|
|
53
|
-
<h1 align="center">Crawlo</h1>
|
|
54
|
-
<p align="center">异步分布式爬虫框架</p>
|
|
55
|
-
<p align="center"><strong>基于 asyncio 的高性能异步分布式爬虫框架,支持单机和分布式部署</strong></p>
|
|
56
|
-
|
|
57
|
-
<p align="center">
|
|
58
|
-
<a href="https://www.python.org/downloads/">
|
|
59
|
-
<img src="https://img.shields.io/badge/python-3.8%2B-blue" alt="Python Version">
|
|
60
|
-
</a>
|
|
61
|
-
<a href="LICENSE">
|
|
62
|
-
<img src="https://img.shields.io/badge/license-MIT-green" alt="License">
|
|
63
|
-
</a>
|
|
64
|
-
<a href="https://crawlo.readthedocs.io/">
|
|
65
|
-
<img src="https://img.shields.io/badge/docs-latest-brightgreen" alt="Documentation">
|
|
66
|
-
</a>
|
|
67
|
-
<a href="https://github.com/crawlo/crawlo/actions">
|
|
68
|
-
<img src="https://github.com/crawlo/crawlo/workflows/CI/badge.svg" alt="CI Status">
|
|
69
|
-
</a>
|
|
70
|
-
</p>
|
|
71
|
-
|
|
72
|
-
<p align="center">
|
|
73
|
-
<a href="#-特性">特性</a> •
|
|
74
|
-
<a href="#-快速开始">快速开始</a> •
|
|
75
|
-
<a href="#-命令行工具">命令行工具</a> •
|
|
76
|
-
<a href="
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<th
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
<td
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
<td
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
<td
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
<td
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
<td
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
<td
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
<td
|
|
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
|
-
crawlo
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
crawlo startproject
|
|
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
|
-
crawlo run
|
|
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
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
crawlo check
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
crawlo stats
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
<
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
<td
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
<td
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
<td
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
<td
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
<td
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
<td
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
<td
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
<td
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
<td
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
<
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
<
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
<td
|
|
423
|
-
<td
|
|
424
|
-
<td
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
<td
|
|
429
|
-
<td
|
|
430
|
-
<td
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
├──
|
|
446
|
-
├──
|
|
447
|
-
├──
|
|
448
|
-
├──
|
|
449
|
-
├──
|
|
450
|
-
├──
|
|
451
|
-
├──
|
|
452
|
-
├──
|
|
453
|
-
├──
|
|
454
|
-
├──
|
|
455
|
-
|
|
456
|
-
├──
|
|
457
|
-
│
|
|
458
|
-
│
|
|
459
|
-
|
|
460
|
-
│
|
|
461
|
-
|
|
462
|
-
│
|
|
463
|
-
|
|
464
|
-
├──
|
|
465
|
-
│ ├──
|
|
466
|
-
│
|
|
467
|
-
│
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
│ ├──
|
|
471
|
-
│ ├──
|
|
472
|
-
│
|
|
473
|
-
│
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
│ ├──
|
|
477
|
-
│ ├──
|
|
478
|
-
│
|
|
479
|
-
│
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
│ ├──
|
|
483
|
-
│ ├──
|
|
484
|
-
│
|
|
485
|
-
│
|
|
486
|
-
├──
|
|
487
|
-
│ ├──
|
|
488
|
-
│ ├──
|
|
489
|
-
│ ├──
|
|
490
|
-
│
|
|
491
|
-
│
|
|
492
|
-
|
|
493
|
-
│ ├──
|
|
494
|
-
│ ├──
|
|
495
|
-
│
|
|
496
|
-
│
|
|
497
|
-
├──
|
|
498
|
-
│ ├──
|
|
499
|
-
│
|
|
500
|
-
│
|
|
501
|
-
|
|
502
|
-
│ ├──
|
|
503
|
-
│ ├──
|
|
504
|
-
│
|
|
505
|
-
│
|
|
506
|
-
├──
|
|
507
|
-
│ ├──
|
|
508
|
-
│ ├──
|
|
509
|
-
│
|
|
510
|
-
│
|
|
511
|
-
|
|
512
|
-
│ ├──
|
|
513
|
-
│ ├──
|
|
514
|
-
│ └──
|
|
515
|
-
│
|
|
516
|
-
├──
|
|
517
|
-
│ ├── __init__.py
|
|
518
|
-
│ ├──
|
|
519
|
-
│
|
|
520
|
-
│
|
|
521
|
-
|
|
522
|
-
│
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
#
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
#
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
#
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
#
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
#
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
- **
|
|
643
|
-
- **
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
- **
|
|
648
|
-
- **
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
- [
|
|
675
|
-
- [
|
|
676
|
-
- [
|
|
677
|
-
- [
|
|
678
|
-
- [
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
<!-- 许可证 section -->
|
|
695
|
-
<h2 align="center">📄 许可证</h2>
|
|
696
|
-
|
|
697
|
-
本项目采用 MIT 许可证,详情请见 [LICENSE](LICENSE) 文件。
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: crawlo
|
|
3
|
+
Version: 1.2.2
|
|
4
|
+
Summary: Crawlo 是一款基于异步IO的高性能Python爬虫框架,支持分布式抓取。
|
|
5
|
+
Home-page: https://github.com/crawl-coder/Crawlo.git
|
|
6
|
+
Author: crawl-coder
|
|
7
|
+
Author-email: crawlo@qq.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.6
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
Requires-Dist: aiohttp>=3.12.14
|
|
15
|
+
Requires-Dist: aiomysql>=0.2.0
|
|
16
|
+
Requires-Dist: aioredis>=2.0.1
|
|
17
|
+
Requires-Dist: asyncmy>=0.2.10
|
|
18
|
+
Requires-Dist: cssselect>=1.2.0
|
|
19
|
+
Requires-Dist: dateparser>=1.2.2
|
|
20
|
+
Requires-Dist: httpx[http2]>=0.27.0
|
|
21
|
+
Requires-Dist: curl-cffi>=0.13.0
|
|
22
|
+
Requires-Dist: lxml>=5.2.1
|
|
23
|
+
Requires-Dist: motor>=3.7.0
|
|
24
|
+
Requires-Dist: parsel>=1.9.1
|
|
25
|
+
Requires-Dist: pydantic>=2.11.7
|
|
26
|
+
Requires-Dist: pymongo>=4.11
|
|
27
|
+
Requires-Dist: PyMySQL>=1.1.1
|
|
28
|
+
Requires-Dist: python-dateutil>=2.9.0.post0
|
|
29
|
+
Requires-Dist: redis>=6.2.0
|
|
30
|
+
Requires-Dist: requests>=2.32.4
|
|
31
|
+
Requires-Dist: six>=1.17.0
|
|
32
|
+
Requires-Dist: ujson>=5.9.0
|
|
33
|
+
Requires-Dist: urllib3>=2.5.0
|
|
34
|
+
Requires-Dist: w3lib>=2.1.2
|
|
35
|
+
Requires-Dist: rich>=14.1.0
|
|
36
|
+
Requires-Dist: astor>=0.8.1
|
|
37
|
+
Requires-Dist: watchdog>=6.0.0
|
|
38
|
+
Provides-Extra: render
|
|
39
|
+
Requires-Dist: webdriver-manager>=4.0.0; extra == "render"
|
|
40
|
+
Requires-Dist: playwright; extra == "render"
|
|
41
|
+
Requires-Dist: selenium>=3.141.0; extra == "render"
|
|
42
|
+
Provides-Extra: all
|
|
43
|
+
Requires-Dist: bitarray>=1.5.3; extra == "all"
|
|
44
|
+
Requires-Dist: PyExecJS>=1.5.1; extra == "all"
|
|
45
|
+
Requires-Dist: pymongo>=3.10.1; extra == "all"
|
|
46
|
+
Requires-Dist: redis-py-cluster>=2.1.0; extra == "all"
|
|
47
|
+
Requires-Dist: webdriver-manager>=4.0.0; extra == "all"
|
|
48
|
+
Requires-Dist: playwright; extra == "all"
|
|
49
|
+
Requires-Dist: selenium>=3.141.0; extra == "all"
|
|
50
|
+
|
|
51
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
52
|
+
<div align="center">
|
|
53
|
+
<h1 align="center">Crawlo</h1>
|
|
54
|
+
<p align="center">异步分布式爬虫框架</p>
|
|
55
|
+
<p align="center"><strong>基于 asyncio 的高性能异步分布式爬虫框架,支持单机和分布式部署</strong></p>
|
|
56
|
+
|
|
57
|
+
<p align="center">
|
|
58
|
+
<a href="https://www.python.org/downloads/">
|
|
59
|
+
<img src="https://img.shields.io/badge/python-3.8%2B-blue" alt="Python Version">
|
|
60
|
+
</a>
|
|
61
|
+
<a href="LICENSE">
|
|
62
|
+
<img src="https://img.shields.io/badge/license-MIT-green" alt="License">
|
|
63
|
+
</a>
|
|
64
|
+
<a href="https://crawlo.readthedocs.io/">
|
|
65
|
+
<img src="https://img.shields.io/badge/docs-latest-brightgreen" alt="Documentation">
|
|
66
|
+
</a>
|
|
67
|
+
<a href="https://github.com/crawlo/crawlo/actions">
|
|
68
|
+
<img src="https://github.com/crawlo/crawlo/workflows/CI/badge.svg" alt="CI Status">
|
|
69
|
+
</a>
|
|
70
|
+
</p>
|
|
71
|
+
|
|
72
|
+
<p align="center">
|
|
73
|
+
<a href="#-特性">特性</a> •
|
|
74
|
+
<a href="#-快速开始">快速开始</a> •
|
|
75
|
+
<a href="#-命令行工具">命令行工具</a> •
|
|
76
|
+
<a href="#-示例项目">示例项目</a>
|
|
77
|
+
</p>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<br />
|
|
81
|
+
|
|
82
|
+
<!-- 特性 section -->
|
|
83
|
+
<div align="center">
|
|
84
|
+
<h2>🌟 特性</h2>
|
|
85
|
+
|
|
86
|
+
<table>
|
|
87
|
+
<thead>
|
|
88
|
+
<tr>
|
|
89
|
+
<th>特性</th>
|
|
90
|
+
<th>描述</th>
|
|
91
|
+
</tr>
|
|
92
|
+
</thead>
|
|
93
|
+
<tbody>
|
|
94
|
+
<tr>
|
|
95
|
+
<td>⚡ <strong>异步高性能</strong></td>
|
|
96
|
+
<td>基于 asyncio 实现,充分利用现代 CPU 夯性能</td>
|
|
97
|
+
</tr>
|
|
98
|
+
<tr>
|
|
99
|
+
<td>🌐 <strong>分布式支持</strong></td>
|
|
100
|
+
<td>内置 Redis 队列,轻松实现分布式部署</td>
|
|
101
|
+
</tr>
|
|
102
|
+
<tr>
|
|
103
|
+
<td>🔧 <strong>模块化设计</strong></td>
|
|
104
|
+
<td>中间件、管道、扩展组件系统,易于定制和扩展</td>
|
|
105
|
+
</tr>
|
|
106
|
+
<tr>
|
|
107
|
+
<td>🔄 <strong>智能去重</strong></td>
|
|
108
|
+
<td>多种去重策略(内存、Redis、Bloom Filter)</td>
|
|
109
|
+
</tr>
|
|
110
|
+
<tr>
|
|
111
|
+
<td>⚙️ <strong>灵活配置</strong></td>
|
|
112
|
+
<td>支持多种配置方式,适应不同场景需求</td>
|
|
113
|
+
</tr>
|
|
114
|
+
<tr>
|
|
115
|
+
<td>📋 <strong>高级日志</strong></td>
|
|
116
|
+
<td>支持日志轮转、结构化日志、JSON格式等高级功能</td>
|
|
117
|
+
</tr>
|
|
118
|
+
<tr>
|
|
119
|
+
<td>📚 <strong>丰富文档</strong></td>
|
|
120
|
+
<td>完整的中英文双语文档和示例项目</td>
|
|
121
|
+
</tr>
|
|
122
|
+
</tbody>
|
|
123
|
+
</table>
|
|
124
|
+
</div>
|
|
125
|
+
|
|
126
|
+
<br />
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
<!-- 快速开始 section -->
|
|
131
|
+
<h2 align="center">🚀 快速开始</h2>
|
|
132
|
+
|
|
133
|
+
### 安装
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
pip install crawlo
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### 创建项目
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# 创建默认项目
|
|
143
|
+
crawlo startproject myproject
|
|
144
|
+
|
|
145
|
+
# 创建分布式模板项目
|
|
146
|
+
crawlo startproject myproject distributed
|
|
147
|
+
|
|
148
|
+
# 创建项目并选择特定模块
|
|
149
|
+
crawlo startproject myproject --modules mysql,redis,proxy
|
|
150
|
+
|
|
151
|
+
cd myproject
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 生成爬虫
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# 在项目目录中生成爬虫
|
|
158
|
+
crawlo genspider news_spider news.example.com
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 编写爬虫
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
from crawlo import Spider, Request, Item
|
|
165
|
+
|
|
166
|
+
class MyItem(Item):
|
|
167
|
+
title = ''
|
|
168
|
+
url = ''
|
|
169
|
+
|
|
170
|
+
class MySpider(Spider):
|
|
171
|
+
name = 'myspider'
|
|
172
|
+
|
|
173
|
+
async def start_requests(self):
|
|
174
|
+
yield Request('https://httpbin.org/get', callback=self.parse)
|
|
175
|
+
|
|
176
|
+
async def parse(self, response):
|
|
177
|
+
yield MyItem(
|
|
178
|
+
title='Example Title',
|
|
179
|
+
url=response.url
|
|
180
|
+
)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### 运行爬虫
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
# 使用命令行工具运行爬虫(推荐)
|
|
187
|
+
crawlo run myspider
|
|
188
|
+
|
|
189
|
+
# 使用项目自带的 run.py 脚本运行
|
|
190
|
+
python run.py
|
|
191
|
+
|
|
192
|
+
# 运行所有爬虫
|
|
193
|
+
crawlo run all
|
|
194
|
+
|
|
195
|
+
# 在项目子目录中也能正确运行
|
|
196
|
+
cd subdirectory
|
|
197
|
+
crawlo run myspider
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
<!-- 命令行工具 section -->
|
|
203
|
+
<h2 align="center">📜 命令行工具</h2>
|
|
204
|
+
|
|
205
|
+
Crawlo 提供了丰富的命令行工具来帮助开发和管理爬虫项目:
|
|
206
|
+
|
|
207
|
+
### 获取帮助
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# 显示帮助信息
|
|
211
|
+
crawlo -h
|
|
212
|
+
crawlo --help
|
|
213
|
+
crawlo help
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### crawlo startproject
|
|
217
|
+
|
|
218
|
+
创建新的爬虫项目。
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# 基本用法
|
|
222
|
+
crawlo startproject <project_name> [template_type] [--modules module1,module2]
|
|
223
|
+
|
|
224
|
+
# 示例
|
|
225
|
+
crawlo startproject my_spider_project
|
|
226
|
+
crawlo startproject news_crawler simple
|
|
227
|
+
crawlo startproject ecommerce_spider distributed --modules mysql,proxy
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**参数说明:**
|
|
231
|
+
- `project_name`: 项目名称(必须是有效的Python标识符)
|
|
232
|
+
- `template_type`: 模板类型(可选)
|
|
233
|
+
- `default`: 默认模板 - 通用配置,适合大多数项目
|
|
234
|
+
- `simple`: 简化模板 - 最小配置,适合快速开始
|
|
235
|
+
- `distributed`: 分布式模板 - 针对分布式爬取优化
|
|
236
|
+
- `high-performance`: 高性能模板 - 针对大规模高并发优化
|
|
237
|
+
- `gentle`: 温和模板 - 低负载配置,对目标网站友好
|
|
238
|
+
- `--modules`: 选择要包含的模块组件(可选)
|
|
239
|
+
- `mysql`: MySQL数据库支持
|
|
240
|
+
- `mongodb`: MongoDB数据库支持
|
|
241
|
+
- `redis`: Redis支持(分布式队列和去重)
|
|
242
|
+
- `proxy`: 代理支持
|
|
243
|
+
- `monitoring`: 监控和性能分析
|
|
244
|
+
- `dedup`: 去重功能
|
|
245
|
+
- `httpx`: HttpX下载器
|
|
246
|
+
- `aiohttp`: AioHttp下载器
|
|
247
|
+
- `curl`: CurlCffi下载器
|
|
248
|
+
|
|
249
|
+
### crawlo genspider
|
|
250
|
+
|
|
251
|
+
在现有项目中生成新的爬虫。
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
# 基本用法
|
|
255
|
+
crawlo genspider <spider_name> <domain>
|
|
256
|
+
|
|
257
|
+
# 示例
|
|
258
|
+
crawlo genspider news_spider news.example.com
|
|
259
|
+
crawlo genspider product_spider shop.example.com
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**参数说明:**
|
|
263
|
+
- `spider_name`: 爬虫名称(必须是有效的Python标识符)
|
|
264
|
+
- `domain`: 目标域名
|
|
265
|
+
|
|
266
|
+
### crawlo run
|
|
267
|
+
|
|
268
|
+
运行爬虫。
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
# 基本用法
|
|
272
|
+
crawlo run <spider_name>|all [--json] [--no-stats]
|
|
273
|
+
|
|
274
|
+
# 示例
|
|
275
|
+
crawlo run myspider
|
|
276
|
+
crawlo run all
|
|
277
|
+
crawlo run all --json --no-stats
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**参数说明:**
|
|
281
|
+
- `spider_name`: 要运行的爬虫名称
|
|
282
|
+
- `all`: 运行所有爬虫
|
|
283
|
+
- `--json`: 以JSON格式输出结果
|
|
284
|
+
- `--no-stats`: 不记录统计信息
|
|
285
|
+
|
|
286
|
+
### crawlo list
|
|
287
|
+
|
|
288
|
+
列出项目中所有可用的爬虫。
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
# 基本用法
|
|
292
|
+
crawlo list [--json]
|
|
293
|
+
|
|
294
|
+
# 示例
|
|
295
|
+
crawlo list
|
|
296
|
+
crawlo list --json
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
**参数说明:**
|
|
300
|
+
- `--json`: 以JSON格式输出结果
|
|
301
|
+
|
|
302
|
+
### crawlo check
|
|
303
|
+
|
|
304
|
+
检查爬虫定义的合规性。
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
# 基本用法
|
|
308
|
+
crawlo check [--fix] [--ci] [--json] [--watch]
|
|
309
|
+
|
|
310
|
+
# 示例
|
|
311
|
+
crawlo check
|
|
312
|
+
crawlo check --fix
|
|
313
|
+
crawlo check --ci
|
|
314
|
+
crawlo check --watch
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**参数说明:**
|
|
318
|
+
- `--fix`: 自动修复常见问题
|
|
319
|
+
- `--ci`: CI模式输出(简洁格式)
|
|
320
|
+
- `--json`: 以JSON格式输出结果
|
|
321
|
+
- `--watch`: 监听模式,文件更改时自动检查
|
|
322
|
+
|
|
323
|
+
### crawlo stats
|
|
324
|
+
|
|
325
|
+
查看爬虫运行统计信息。
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
# 基本用法
|
|
329
|
+
crawlo stats [spider_name] [--all]
|
|
330
|
+
|
|
331
|
+
# 示例
|
|
332
|
+
crawlo stats
|
|
333
|
+
crawlo stats myspider
|
|
334
|
+
crawlo stats myspider --all
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**参数说明:**
|
|
338
|
+
- `spider_name`: 指定要查看统计信息的爬虫名称
|
|
339
|
+
- `--all`: 显示指定爬虫的所有历史运行记录
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
<!-- 架构设计 section -->
|
|
344
|
+
<h2 align="center">🏗️ 架构设计</h2>
|
|
345
|
+
|
|
346
|
+
### 核心组件说明
|
|
347
|
+
|
|
348
|
+
Crawlo 框架由以下核心组件构成:
|
|
349
|
+
|
|
350
|
+
<table>
|
|
351
|
+
<thead>
|
|
352
|
+
<tr>
|
|
353
|
+
<th>组件</th>
|
|
354
|
+
<th>功能描述</th>
|
|
355
|
+
</tr>
|
|
356
|
+
</thead>
|
|
357
|
+
<tbody>
|
|
358
|
+
<tr>
|
|
359
|
+
<td><strong>Crawler</strong></td>
|
|
360
|
+
<td>爬虫运行实例,管理Spider与引擎的生命周期</td>
|
|
361
|
+
</tr>
|
|
362
|
+
<tr>
|
|
363
|
+
<td><strong>Engine</strong></td>
|
|
364
|
+
<td>引擎组件,协调Scheduler、Downloader、Processor</td>
|
|
365
|
+
</tr>
|
|
366
|
+
<tr>
|
|
367
|
+
<td><strong>Scheduler</strong></td>
|
|
368
|
+
<td>调度器,管理请求队列和去重过滤</td>
|
|
369
|
+
</tr>
|
|
370
|
+
<tr>
|
|
371
|
+
<td><strong>Downloader</strong></td>
|
|
372
|
+
<td>下载器,负责网络请求,支持多种实现(aiohttp, httpx, curl-cffi)</td>
|
|
373
|
+
</tr>
|
|
374
|
+
<tr>
|
|
375
|
+
<td><strong>Processor</strong></td>
|
|
376
|
+
<td>处理器,处理响应数据和管道</td>
|
|
377
|
+
</tr>
|
|
378
|
+
<tr>
|
|
379
|
+
<td><strong>QueueManager</strong></td>
|
|
380
|
+
<td>统一的队列管理器,支持内存队列和Redis队列的自动切换</td>
|
|
381
|
+
</tr>
|
|
382
|
+
<tr>
|
|
383
|
+
<td><strong>Filter</strong></td>
|
|
384
|
+
<td>请求去重过滤器,支持内存和Redis两种实现</td>
|
|
385
|
+
</tr>
|
|
386
|
+
<tr>
|
|
387
|
+
<td><strong>Middleware</strong></td>
|
|
388
|
+
<td>中间件系统,处理请求/响应的预处理和后处理</td>
|
|
389
|
+
</tr>
|
|
390
|
+
<tr>
|
|
391
|
+
<td><strong>Pipeline</strong></td>
|
|
392
|
+
<td>数据处理管道,支持多种存储方式(控制台、数据库等)和去重功能</td>
|
|
393
|
+
</tr>
|
|
394
|
+
<tr>
|
|
395
|
+
<td><strong>Spider</strong></td>
|
|
396
|
+
<td>爬虫基类,定义爬取逻辑</td>
|
|
397
|
+
</tr>
|
|
398
|
+
</tbody>
|
|
399
|
+
</table>
|
|
400
|
+
|
|
401
|
+
### 运行模式
|
|
402
|
+
|
|
403
|
+
Crawlo支持三种运行模式:
|
|
404
|
+
|
|
405
|
+
<table>
|
|
406
|
+
<thead>
|
|
407
|
+
<tr>
|
|
408
|
+
<th>模式</th>
|
|
409
|
+
<th>描述</th>
|
|
410
|
+
<th>队列类型</th>
|
|
411
|
+
<th>过滤器类型</th>
|
|
412
|
+
</tr>
|
|
413
|
+
</thead>
|
|
414
|
+
<tbody>
|
|
415
|
+
<tr>
|
|
416
|
+
<td><strong>standalone</strong></td>
|
|
417
|
+
<td>单机模式</td>
|
|
418
|
+
<td>内存队列</td>
|
|
419
|
+
<td>内存过滤器</td>
|
|
420
|
+
</tr>
|
|
421
|
+
<tr>
|
|
422
|
+
<td><strong>distributed</strong></td>
|
|
423
|
+
<td>分布式模式</td>
|
|
424
|
+
<td>Redis队列</td>
|
|
425
|
+
<td>Redis过滤器</td>
|
|
426
|
+
</tr>
|
|
427
|
+
<tr>
|
|
428
|
+
<td><strong>auto</strong></td>
|
|
429
|
+
<td>自动检测模式</td>
|
|
430
|
+
<td>根据环境自动选择最佳运行方式</td>
|
|
431
|
+
<td>根据环境自动选择</td>
|
|
432
|
+
</tr>
|
|
433
|
+
</tbody>
|
|
434
|
+
</table>
|
|
435
|
+
|
|
436
|
+
### 模块层次结构
|
|
437
|
+
|
|
438
|
+
```
|
|
439
|
+
crawlo/
|
|
440
|
+
├── cli.py # 命令行接口
|
|
441
|
+
├── crawler.py # 爬虫运行实例
|
|
442
|
+
├── project.py # 项目管理
|
|
443
|
+
├── config.py # 配置管理
|
|
444
|
+
├── mode_manager.py # 运行模式管理器
|
|
445
|
+
├── stats_collector.py # 统计收集器
|
|
446
|
+
├── subscriber.py # 事件订阅器
|
|
447
|
+
├── task_manager.py # 任务管理器
|
|
448
|
+
├── event.py # 事件定义
|
|
449
|
+
├── exceptions.py # 异常定义
|
|
450
|
+
├──
|
|
451
|
+
├── core/ # 核心组件
|
|
452
|
+
│ ├── engine.py # 引擎
|
|
453
|
+
│ ├── scheduler.py # 调度器
|
|
454
|
+
│ ├── processor.py # 处理器
|
|
455
|
+
│
|
|
456
|
+
├── spider/ # 爬虫基类
|
|
457
|
+
│ └── __init__.py # 爬虫元类和基类
|
|
458
|
+
│
|
|
459
|
+
├── network/ # 网络相关
|
|
460
|
+
│ ├── request.py # 请求对象
|
|
461
|
+
│ └── response.py # 响应对象
|
|
462
|
+
│
|
|
463
|
+
├── downloader/ # 下载器
|
|
464
|
+
│ ├── __init__.py # 下载器基类
|
|
465
|
+
│ ├── aiohttp_downloader.py # AioHttp实现
|
|
466
|
+
│ ├── httpx_downloader.py # HttpX实现
|
|
467
|
+
│ └── cffi_downloader.py # CurlCffi实现
|
|
468
|
+
│
|
|
469
|
+
├── queue/ # 队列管理
|
|
470
|
+
│ ├── __init__.py
|
|
471
|
+
│ ├── queue_manager.py # 队列管理器
|
|
472
|
+
│ ├── pqueue.py # 内存优先队列
|
|
473
|
+
│ └── redis_priority_queue.py # Redis优先队列
|
|
474
|
+
│
|
|
475
|
+
├── filters/ # 过滤器
|
|
476
|
+
│ ├── __init__.py
|
|
477
|
+
│ ├── base_filter.py # 过滤器基类
|
|
478
|
+
│ ├── memory_filter.py # 内存过滤器
|
|
479
|
+
│ └── aioredis_filter.py # Redis过滤器
|
|
480
|
+
│
|
|
481
|
+
├── middleware/ # 中间件
|
|
482
|
+
│ ├── __init__.py
|
|
483
|
+
│ ├── middleware_manager.py # 中间件管理器
|
|
484
|
+
│ ├── default_header.py # 默认请求头
|
|
485
|
+
│ ├── download_delay.py # 下载延迟
|
|
486
|
+
│ ├── proxy.py # 代理支持
|
|
487
|
+
│ ├── request_ignore.py # 请求忽略
|
|
488
|
+
│ ├── response_code.py # 响应码处理
|
|
489
|
+
│ ├── response_filter.py # 响应过滤
|
|
490
|
+
│ └── retry.py # 重试机制
|
|
491
|
+
│
|
|
492
|
+
├── pipelines/ # 数据管道
|
|
493
|
+
│ ├── __init__.py
|
|
494
|
+
│ ├── pipeline_manager.py # 管道管理器
|
|
495
|
+
│ ├── base_pipeline.py # 管道基类
|
|
496
|
+
│ ├── console_pipeline.py # 控制台输出管道
|
|
497
|
+
│ ├── json_pipeline.py # JSON存储管道
|
|
498
|
+
│ ├── redis_dedup_pipeline.py # Redis去重管道
|
|
499
|
+
│ └── mysql_pipeline.py # MySQL存储管道
|
|
500
|
+
│
|
|
501
|
+
├── extension/ # 扩展组件
|
|
502
|
+
│ ├── __init__.py
|
|
503
|
+
│ ├── log_interval.py # 定时日志
|
|
504
|
+
│ ├── log_stats.py # 统计日志
|
|
505
|
+
│ ├── logging_extension.py # 日志扩展
|
|
506
|
+
│ ├── memory_monitor.py # 内存监控
|
|
507
|
+
│ ├── performance_profiler.py # 性能分析
|
|
508
|
+
│ ├── health_check.py # 健康检查
|
|
509
|
+
│ └── request_recorder.py # 请求记录
|
|
510
|
+
│
|
|
511
|
+
├── settings/ # 配置系统
|
|
512
|
+
│ ├── __init__.py
|
|
513
|
+
│ ├── default_settings.py # 默认配置
|
|
514
|
+
│ └── setting_manager.py # 配置管理器
|
|
515
|
+
│
|
|
516
|
+
├── utils/ # 工具库
|
|
517
|
+
│ ├── __init__.py
|
|
518
|
+
│ ├── log.py # 基础日志工具
|
|
519
|
+
│ ├── request.py # 请求工具
|
|
520
|
+
│ ├── request_serializer.py # 请求序列化
|
|
521
|
+
│ └── func_tools.py # 函数工具
|
|
522
|
+
│
|
|
523
|
+
└── templates/ # 模板文件
|
|
524
|
+
├── project/
|
|
525
|
+
└── spider/
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
---
|
|
529
|
+
|
|
530
|
+
<!-- 配置系统 section -->
|
|
531
|
+
<h2 align="center">🎛️ 配置系统</h2>
|
|
532
|
+
|
|
533
|
+
### 传统配置方式
|
|
534
|
+
|
|
535
|
+
```
|
|
536
|
+
# settings.py
|
|
537
|
+
PROJECT_NAME = 'myproject'
|
|
538
|
+
CONCURRENCY = 16
|
|
539
|
+
DOWNLOAD_DELAY = 1.0
|
|
540
|
+
QUEUE_TYPE = 'memory' # 单机模式
|
|
541
|
+
# QUEUE_TYPE = 'redis' # 分布式模式
|
|
542
|
+
|
|
543
|
+
# Redis 配置 (分布式模式下使用)
|
|
544
|
+
REDIS_HOST = 'localhost'
|
|
545
|
+
REDIS_PORT = 6379
|
|
546
|
+
REDIS_DB = 0
|
|
547
|
+
REDIS_PASSWORD = ''
|
|
548
|
+
|
|
549
|
+
# 数据管道配置
|
|
550
|
+
PIPELINES = [
|
|
551
|
+
'crawlo.pipelines.console_pipeline.ConsolePipeline',
|
|
552
|
+
'crawlo.pipelines.json_pipeline.JsonPipeline',
|
|
553
|
+
'crawlo.pipelines.redis_dedup_pipeline.RedisDedupPipeline', # Redis去重管道
|
|
554
|
+
'crawlo.pipelines.mysql_pipeline.AsyncmyMySQLPipeline', # MySQL存储管道
|
|
555
|
+
]
|
|
556
|
+
|
|
557
|
+
# 高级日志配置
|
|
558
|
+
LOG_FILE = 'logs/spider.log'
|
|
559
|
+
LOG_LEVEL = 'INFO'
|
|
560
|
+
LOG_MAX_BYTES = 10 * 1024 * 1024 # 10MB
|
|
561
|
+
LOG_BACKUP_COUNT = 5
|
|
562
|
+
LOG_JSON_FORMAT = False # 设置为True启用JSON格式
|
|
563
|
+
|
|
564
|
+
# 启用高级日志扩展
|
|
565
|
+
ADVANCED_LOGGING_ENABLED = True
|
|
566
|
+
|
|
567
|
+
# 启用日志监控
|
|
568
|
+
LOG_MONITOR_ENABLED = True
|
|
569
|
+
LOG_MONITOR_INTERVAL = 30
|
|
570
|
+
LOG_MONITOR_DETAILED_STATS = True
|
|
571
|
+
|
|
572
|
+
# 添加扩展
|
|
573
|
+
EXTENSIONS = [
|
|
574
|
+
'crawlo.extension.log_interval.LogIntervalExtension',
|
|
575
|
+
'crawlo.extension.log_stats.LogStats',
|
|
576
|
+
'crawlo.extension.logging_extension.CustomLoggerExtension',
|
|
577
|
+
'crawlo.extension.memory_monitor.MemoryMonitorExtension',
|
|
578
|
+
]
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
### MySQL 管道配置
|
|
582
|
+
|
|
583
|
+
Crawlo 提供了现成的 MySQL 管道实现,可以轻松将爬取的数据存储到 MySQL 数据库中:
|
|
584
|
+
|
|
585
|
+
```
|
|
586
|
+
# 在 settings.py 中启用 MySQL 管道
|
|
587
|
+
PIPELINES = [
|
|
588
|
+
'crawlo.pipelines.mysql_pipeline.AsyncmyMySQLPipeline',
|
|
589
|
+
]
|
|
590
|
+
|
|
591
|
+
# MySQL 数据库配置
|
|
592
|
+
MYSQL_HOST = 'localhost'
|
|
593
|
+
MYSQL_PORT = 3306
|
|
594
|
+
MYSQL_USER = 'your_username'
|
|
595
|
+
MYSQL_PASSWORD = 'your_password'
|
|
596
|
+
MYSQL_DB = 'your_database'
|
|
597
|
+
MYSQL_TABLE = 'your_table_name'
|
|
598
|
+
|
|
599
|
+
# 可选的批量插入配置
|
|
600
|
+
MYSQL_BATCH_SIZE = 100
|
|
601
|
+
MYSQL_USE_BATCH = True
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
MySQL 管道特性:
|
|
605
|
+
- **异步操作**:基于 asyncmy 驱动,提供高性能的异步数据库操作
|
|
606
|
+
- **连接池**:自动管理数据库连接,提高效率
|
|
607
|
+
- **批量插入**:支持批量插入以提高性能
|
|
608
|
+
- **事务支持**:确保数据一致性
|
|
609
|
+
- **灵活配置**:支持自定义表名、批量大小等参数
|
|
610
|
+
|
|
611
|
+
### 命令行配置
|
|
612
|
+
|
|
613
|
+
```
|
|
614
|
+
# 运行单个爬虫
|
|
615
|
+
crawlo run myspider
|
|
616
|
+
|
|
617
|
+
# 运行所有爬虫
|
|
618
|
+
crawlo run all
|
|
619
|
+
|
|
620
|
+
# 在项目子目录中也能正确运行
|
|
621
|
+
cd subdirectory
|
|
622
|
+
crawlo run myspider
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
---
|
|
626
|
+
|
|
627
|
+
<!-- 核心组件 section -->
|
|
628
|
+
<h2 align="center">🧩 核心组件</h2>
|
|
629
|
+
|
|
630
|
+
### 中间件系统
|
|
631
|
+
灵活的中间件系统,支持请求预处理、响应处理和异常处理。
|
|
632
|
+
|
|
633
|
+
### 管道系统
|
|
634
|
+
可扩展的数据处理管道,支持多种存储方式(控制台、数据库等)和去重功能:
|
|
635
|
+
- **ConsolePipeline**: 控制台输出管道
|
|
636
|
+
- **JsonPipeline**: JSON文件存储管道
|
|
637
|
+
- **RedisDedupPipeline**: Redis去重管道,基于Redis集合实现分布式去重
|
|
638
|
+
- **AsyncmyMySQLPipeline**: MySQL数据库存储管道,基于asyncmy驱动
|
|
639
|
+
|
|
640
|
+
### 扩展组件
|
|
641
|
+
功能增强扩展,包括日志、监控、性能分析等:
|
|
642
|
+
- **LogIntervalExtension**: 定时日志扩展
|
|
643
|
+
- **LogStats**: 统计日志扩展
|
|
644
|
+
- **CustomLoggerExtension**: 自定义日志扩展
|
|
645
|
+
- **MemoryMonitorExtension**: 内存监控扩展
|
|
646
|
+
- **PerformanceProfilerExtension**: 性能分析扩展
|
|
647
|
+
- **HealthCheckExtension**: 健康检查扩展
|
|
648
|
+
- **RequestRecorderExtension**: 请求记录扩展
|
|
649
|
+
|
|
650
|
+
### 过滤系统
|
|
651
|
+
智能去重过滤,支持多种去重策略(内存、Redis、Bloom Filter)。
|
|
652
|
+
|
|
653
|
+
---
|
|
654
|
+
|
|
655
|
+
<!-- 示例项目 section -->
|
|
656
|
+
<h2 align="center">📦 示例项目</h2>
|
|
657
|
+
|
|
658
|
+
- [OFweek分布式爬虫](examples/ofweek_distributed/) - 复杂的分布式爬虫示例,包含Redis去重功能
|
|
659
|
+
- [OFweek独立爬虫](examples/ofweek_standalone/) - 独立运行的爬虫示例
|
|
660
|
+
- [OFweek混合模式爬虫](examples/ofweek_spider/) - 支持单机和分布式模式切换的爬虫示例
|
|
661
|
+
|
|
662
|
+
---
|
|
663
|
+
|
|
664
|
+
<!-- 文档 section -->
|
|
665
|
+
<h2 align="center">📚 文档</h2>
|
|
666
|
+
|
|
667
|
+
完整的文档请访问 [Crawlo Documentation](https://crawlo.readthedocs.io/)
|
|
668
|
+
|
|
669
|
+
- [快速开始指南](docs/modules/index.md)
|
|
670
|
+
- [模块化文档](docs/modules/index.md)
|
|
671
|
+
- [核心引擎文档](docs/modules/core/engine.md)
|
|
672
|
+
- [调度器文档](docs/modules/core/scheduler.md)
|
|
673
|
+
- [下载器文档](docs/modules/downloader/index.md)
|
|
674
|
+
- [中间件文档](docs/modules/middleware/index.md)
|
|
675
|
+
- [管道文档](docs/modules/pipeline/index.md)
|
|
676
|
+
- [队列文档](docs/modules/queue/index.md)
|
|
677
|
+
- [过滤器文档](docs/modules/filter/index.md)
|
|
678
|
+
- [扩展组件文档](docs/modules/extension/index.md)
|
|
679
|
+
|
|
680
|
+
---
|
|
681
|
+
|
|
682
|
+
<!-- 贡献 section -->
|
|
683
|
+
<h2 align="center">🤝 贡献</h2>
|
|
684
|
+
|
|
685
|
+
欢迎提交 Issue 和 Pull Request 来帮助改进 Crawlo!
|
|
686
|
+
|
|
687
|
+
---
|
|
688
|
+
|
|
689
|
+
<!-- 许可证 section -->
|
|
690
|
+
<h2 align="center">📄 许可证</h2>
|
|
691
|
+
|
|
692
|
+
本项目采用 MIT 许可证,详情请见 [LICENSE](LICENSE) 文件。
|