crawlo 1.4.4__py3-none-any.whl → 1.4.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 crawlo might be problematic. Click here for more details.
- crawlo/__init__.py +11 -15
- crawlo/__version__.py +1 -1
- crawlo/commands/startproject.py +24 -0
- crawlo/core/engine.py +2 -2
- crawlo/core/scheduler.py +4 -4
- crawlo/crawler.py +8 -7
- crawlo/downloader/__init__.py +5 -2
- crawlo/downloader/cffi_downloader.py +3 -1
- crawlo/extension/__init__.py +2 -2
- crawlo/filters/aioredis_filter.py +8 -1
- crawlo/filters/memory_filter.py +8 -1
- crawlo/initialization/built_in.py +13 -4
- crawlo/initialization/core.py +5 -4
- crawlo/interfaces.py +24 -0
- crawlo/middleware/__init__.py +7 -4
- crawlo/middleware/middleware_manager.py +15 -8
- crawlo/middleware/proxy.py +171 -348
- crawlo/mode_manager.py +45 -11
- crawlo/network/response.py +374 -69
- crawlo/pipelines/mysql_pipeline.py +340 -189
- crawlo/pipelines/pipeline_manager.py +2 -2
- crawlo/project.py +2 -4
- crawlo/settings/default_settings.py +42 -30
- crawlo/stats_collector.py +10 -1
- crawlo/task_manager.py +2 -2
- crawlo/templates/project/items.py.tmpl +2 -2
- crawlo/templates/project/middlewares.py.tmpl +9 -89
- crawlo/templates/project/pipelines.py.tmpl +8 -68
- crawlo/templates/project/settings.py.tmpl +10 -55
- crawlo/templates/project/settings_distributed.py.tmpl +20 -22
- crawlo/templates/project/settings_gentle.py.tmpl +5 -0
- crawlo/templates/project/settings_high_performance.py.tmpl +5 -0
- crawlo/templates/project/settings_minimal.py.tmpl +25 -1
- crawlo/templates/project/settings_simple.py.tmpl +5 -0
- crawlo/templates/run.py.tmpl +1 -8
- crawlo/templates/spider/spider.py.tmpl +5 -108
- crawlo/tools/__init__.py +0 -11
- crawlo/utils/__init__.py +17 -1
- crawlo/utils/db_helper.py +226 -319
- crawlo/utils/error_handler.py +313 -67
- crawlo/utils/fingerprint.py +3 -4
- crawlo/utils/misc.py +82 -0
- crawlo/utils/request.py +55 -66
- crawlo/utils/selector_helper.py +138 -0
- crawlo/utils/spider_loader.py +185 -45
- crawlo/utils/text_helper.py +95 -0
- crawlo-1.4.6.dist-info/METADATA +329 -0
- {crawlo-1.4.4.dist-info → crawlo-1.4.6.dist-info}/RECORD +110 -69
- tests/authenticated_proxy_example.py +10 -6
- tests/bug_check_test.py +251 -0
- tests/direct_selector_helper_test.py +97 -0
- tests/explain_mysql_update_behavior.py +77 -0
- tests/ofweek_scrapy/ofweek_scrapy/items.py +12 -0
- tests/ofweek_scrapy/ofweek_scrapy/middlewares.py +100 -0
- tests/ofweek_scrapy/ofweek_scrapy/pipelines.py +13 -0
- tests/ofweek_scrapy/ofweek_scrapy/settings.py +85 -0
- tests/ofweek_scrapy/ofweek_scrapy/spiders/__init__.py +4 -0
- tests/ofweek_scrapy/ofweek_scrapy/spiders/ofweek_spider.py +162 -0
- tests/ofweek_scrapy/scrapy.cfg +11 -0
- tests/performance_comparison.py +4 -5
- tests/simple_crawlo_test.py +1 -2
- tests/simple_follow_test.py +39 -0
- tests/simple_response_selector_test.py +95 -0
- tests/simple_selector_helper_test.py +155 -0
- tests/simple_selector_test.py +208 -0
- tests/simple_url_test.py +74 -0
- tests/simulate_mysql_update_test.py +140 -0
- tests/test_asyncmy_usage.py +57 -0
- tests/test_crawler_process_import.py +39 -0
- tests/test_crawler_process_spider_modules.py +48 -0
- tests/test_crawlo_proxy_integration.py +8 -2
- tests/test_downloader_proxy_compatibility.py +24 -20
- tests/test_edge_cases.py +7 -5
- tests/test_encoding_core.py +57 -0
- tests/test_encoding_detection.py +127 -0
- tests/test_factory_compatibility.py +197 -0
- tests/test_mysql_pipeline_config.py +165 -0
- tests/test_mysql_pipeline_error.py +99 -0
- tests/test_mysql_pipeline_init_log.py +83 -0
- tests/test_mysql_pipeline_integration.py +133 -0
- tests/test_mysql_pipeline_refactor.py +144 -0
- tests/test_mysql_pipeline_refactor_simple.py +86 -0
- tests/test_mysql_pipeline_robustness.py +196 -0
- tests/test_mysql_pipeline_types.py +89 -0
- tests/test_mysql_update_columns.py +94 -0
- tests/test_optimized_selector_naming.py +101 -0
- tests/test_priority_behavior.py +18 -18
- tests/test_proxy_middleware.py +104 -8
- tests/test_proxy_middleware_enhanced.py +1 -5
- tests/test_proxy_middleware_integration.py +7 -2
- tests/test_proxy_middleware_refactored.py +25 -2
- tests/test_proxy_only.py +84 -0
- tests/test_proxy_with_downloader.py +153 -0
- tests/test_real_scenario_proxy.py +17 -17
- tests/test_response_follow.py +105 -0
- tests/test_response_selector_methods.py +93 -0
- tests/test_response_url_methods.py +71 -0
- tests/test_response_urljoin.py +87 -0
- tests/test_scrapy_style_encoding.py +113 -0
- tests/test_selector_helper.py +101 -0
- tests/test_selector_optimizations.py +147 -0
- tests/test_spider_loader.py +50 -0
- tests/test_spider_loader_comprehensive.py +70 -0
- tests/test_spiders/__init__.py +1 -0
- tests/test_spiders/test_spider.py +10 -0
- tests/verify_mysql_warnings.py +110 -0
- crawlo/middleware/simple_proxy.py +0 -65
- crawlo/tools/anti_crawler.py +0 -269
- crawlo/utils/class_loader.py +0 -26
- crawlo/utils/enhanced_error_handler.py +0 -357
- crawlo-1.4.4.dist-info/METADATA +0 -190
- tests/simple_log_test.py +0 -58
- tests/simple_test.py +0 -48
- tests/test_framework_logger.py +0 -67
- tests/test_framework_startup.py +0 -65
- tests/test_mode_change.py +0 -73
- {crawlo-1.4.4.dist-info → crawlo-1.4.6.dist-info}/WHEEL +0 -0
- {crawlo-1.4.4.dist-info → crawlo-1.4.6.dist-info}/entry_points.txt +0 -0
- {crawlo-1.4.4.dist-info → crawlo-1.4.6.dist-info}/top_level.txt +0 -0
- /tests/{final_command_test_report.md → ofweek_scrapy/ofweek_scrapy/__init__.py} +0 -0
tests/test_framework_logger.py
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: UTF-8 -*-
|
|
3
|
-
"""
|
|
4
|
-
测试框架日志系统
|
|
5
|
-
"""
|
|
6
|
-
import sys
|
|
7
|
-
import os
|
|
8
|
-
sys.path.insert(0, '/')
|
|
9
|
-
|
|
10
|
-
from crawlo.initialization import initialize_framework, get_framework_initializer
|
|
11
|
-
from crawlo.utils.log import get_logger, LoggerManager
|
|
12
|
-
|
|
13
|
-
def test_framework_logger():
|
|
14
|
-
print("=== 测试框架日志系统 ===")
|
|
15
|
-
|
|
16
|
-
# 1. 初始化框架,传入基本配置
|
|
17
|
-
print("1. 初始化框架...")
|
|
18
|
-
custom_settings = {
|
|
19
|
-
'LOG_LEVEL': 'INFO',
|
|
20
|
-
'LOG_FILE': 'test_framework.log',
|
|
21
|
-
'PROJECT_NAME': 'test_framework',
|
|
22
|
-
'RUN_MODE': 'standalone'
|
|
23
|
-
}
|
|
24
|
-
settings = initialize_framework(custom_settings)
|
|
25
|
-
print(f" LOG_LEVEL: {settings.get('LOG_LEVEL')}")
|
|
26
|
-
print(f" LOG_FILE: {settings.get('LOG_FILE')}")
|
|
27
|
-
|
|
28
|
-
# 2. 获取框架初始化管理器
|
|
29
|
-
init_manager = get_framework_initializer()
|
|
30
|
-
print(f" 框架是否就绪: {init_manager.is_ready}")
|
|
31
|
-
print(f" 初始化阶段: {init_manager.phase}")
|
|
32
|
-
|
|
33
|
-
# 3. 测试框架logger
|
|
34
|
-
framework_logger = init_manager.logger
|
|
35
|
-
if framework_logger:
|
|
36
|
-
print(f" 框架logger名称: {framework_logger.name}")
|
|
37
|
-
print(f" 框架logger级别: {framework_logger.level}")
|
|
38
|
-
print(f" 框架logger处理器数量: {len(framework_logger.handlers)}")
|
|
39
|
-
|
|
40
|
-
for i, handler in enumerate(framework_logger.handlers):
|
|
41
|
-
handler_type = type(handler).__name__
|
|
42
|
-
print(f" 处理器{i}: {handler_type}, 级别: {handler.level}")
|
|
43
|
-
else:
|
|
44
|
-
print(" 框架logger为None!")
|
|
45
|
-
framework_logger = get_logger('crawlo.framework')
|
|
46
|
-
print(f" 手动创建的框架logger: {framework_logger.name}")
|
|
47
|
-
|
|
48
|
-
# 4. 测试日志输出
|
|
49
|
-
print("2. 测试日志输出...")
|
|
50
|
-
framework_logger.info("Crawlo框架初始化完成")
|
|
51
|
-
framework_logger.info("Crawlo Framework Started 1.3.3")
|
|
52
|
-
framework_logger.info("使用单机模式 - 简单快速,适合开发和中小规模爬取")
|
|
53
|
-
framework_logger.info("Run Mode: standalone")
|
|
54
|
-
framework_logger.info("Starting running test_spider")
|
|
55
|
-
|
|
56
|
-
# 5. 测试其他logger
|
|
57
|
-
print("3. 测试其他组件logger...")
|
|
58
|
-
queue_logger = get_logger('QueueManager')
|
|
59
|
-
queue_logger.info("Queue initialized successfully Type: memory")
|
|
60
|
-
|
|
61
|
-
scheduler_logger = get_logger('Scheduler')
|
|
62
|
-
scheduler_logger.info("enabled filters: crawlo.filters.memory_filter.MemoryFilter")
|
|
63
|
-
|
|
64
|
-
print("=== 测试完成 ===")
|
|
65
|
-
|
|
66
|
-
if __name__ == "__main__":
|
|
67
|
-
test_framework_logger()
|
tests/test_framework_startup.py
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
"""
|
|
4
|
-
测试框架启动信息是否正确输出到日志文件
|
|
5
|
-
"""
|
|
6
|
-
import sys
|
|
7
|
-
import os
|
|
8
|
-
sys.path.insert(0, '/')
|
|
9
|
-
|
|
10
|
-
def test_framework_startup():
|
|
11
|
-
print("=== 测试框架启动信息输出 ===")
|
|
12
|
-
|
|
13
|
-
# 删除旧的日志文件
|
|
14
|
-
test_log_file = '/Users/oscar/projects/Crawlo/test_startup.log'
|
|
15
|
-
if os.path.exists(test_log_file):
|
|
16
|
-
os.remove(test_log_file)
|
|
17
|
-
|
|
18
|
-
# 准备测试设置
|
|
19
|
-
test_settings = {
|
|
20
|
-
'PROJECT_NAME': 'test_startup',
|
|
21
|
-
'LOG_LEVEL': 'INFO',
|
|
22
|
-
'LOG_FILE': test_log_file,
|
|
23
|
-
'RUN_MODE': 'standalone'
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
# 初始化框架
|
|
27
|
-
from crawlo.initialization import initialize_framework
|
|
28
|
-
settings = initialize_framework(test_settings)
|
|
29
|
-
|
|
30
|
-
print(f"设置初始化完成: {settings.get('PROJECT_NAME')}")
|
|
31
|
-
|
|
32
|
-
# 检查日志文件是否包含框架启动信息
|
|
33
|
-
if os.path.exists(test_log_file):
|
|
34
|
-
with open(test_log_file, 'r', encoding='utf-8') as f:
|
|
35
|
-
content = f.read()
|
|
36
|
-
print(f"日志文件内容长度: {len(content)} 字符")
|
|
37
|
-
|
|
38
|
-
# 检查关键的框架启动信息
|
|
39
|
-
if "Crawlo框架初始化完成" in content:
|
|
40
|
-
print("✅ 发现: Crawlo框架初始化完成")
|
|
41
|
-
else:
|
|
42
|
-
print("❌ 未找到: Crawlo框架初始化完成")
|
|
43
|
-
|
|
44
|
-
if "Crawlo Framework Started" in content:
|
|
45
|
-
print("✅ 发现: Crawlo Framework Started")
|
|
46
|
-
else:
|
|
47
|
-
print("❌ 未找到: Crawlo Framework Started")
|
|
48
|
-
|
|
49
|
-
if "使用单机模式" in content:
|
|
50
|
-
print("✅ 发现: 使用单机模式")
|
|
51
|
-
else:
|
|
52
|
-
print("❌ 未找到: 使用单机模式")
|
|
53
|
-
|
|
54
|
-
print("\n前50行日志内容:")
|
|
55
|
-
lines = content.split('\n')[:50]
|
|
56
|
-
for i, line in enumerate(lines, 1):
|
|
57
|
-
if any(keyword in line for keyword in ["框架", "Framework", "Started"]):
|
|
58
|
-
print(f"{i:3d}: {line}")
|
|
59
|
-
else:
|
|
60
|
-
print("❌ 日志文件未创建")
|
|
61
|
-
|
|
62
|
-
print("=== 测试完成 ===")
|
|
63
|
-
|
|
64
|
-
if __name__ == "__main__":
|
|
65
|
-
test_framework_startup()
|
tests/test_mode_change.py
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
"""
|
|
4
|
-
测试运行模式日志级别修改
|
|
5
|
-
"""
|
|
6
|
-
import sys
|
|
7
|
-
import os
|
|
8
|
-
sys.path.insert(0, '/')
|
|
9
|
-
|
|
10
|
-
def test_mode_log_level():
|
|
11
|
-
print("=== 测试运行模式日志级别修改 ===")
|
|
12
|
-
|
|
13
|
-
# 删除旧的日志文件
|
|
14
|
-
test_log_file = '/Users/oscar/projects/Crawlo/test_mode_change.log'
|
|
15
|
-
if os.path.exists(test_log_file):
|
|
16
|
-
os.remove(test_log_file)
|
|
17
|
-
|
|
18
|
-
# 准备测试设置
|
|
19
|
-
test_settings = {
|
|
20
|
-
'PROJECT_NAME': 'test_mode_change',
|
|
21
|
-
'LOG_LEVEL': 'INFO',
|
|
22
|
-
'LOG_FILE': test_log_file,
|
|
23
|
-
'RUN_MODE': 'standalone'
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
try:
|
|
27
|
-
# 初始化框架
|
|
28
|
-
from crawlo.initialization import initialize_framework
|
|
29
|
-
settings = initialize_framework(test_settings)
|
|
30
|
-
|
|
31
|
-
print(f"设置初始化完成: {settings.get('PROJECT_NAME')}")
|
|
32
|
-
|
|
33
|
-
# 检查日志文件是否包含运行模式信息
|
|
34
|
-
if os.path.exists(test_log_file):
|
|
35
|
-
with open(test_log_file, 'r', encoding='utf-8') as f:
|
|
36
|
-
content = f.read()
|
|
37
|
-
print(f"日志文件内容长度: {len(content)} 字符")
|
|
38
|
-
|
|
39
|
-
# 检查是否还有INFO级别的运行模式信息
|
|
40
|
-
info_lines = [line for line in content.split('\n') if 'INFO' in line and '使用单机模式' in line]
|
|
41
|
-
debug_lines = [line for line in content.split('\n') if 'DEBUG' in line and '使用单机模式' in line]
|
|
42
|
-
|
|
43
|
-
if info_lines:
|
|
44
|
-
print("❌ 仍然发现INFO级别的运行模式信息:")
|
|
45
|
-
for line in info_lines:
|
|
46
|
-
print(f" {line}")
|
|
47
|
-
else:
|
|
48
|
-
print("✅ 没有发现INFO级别的运行模式信息")
|
|
49
|
-
|
|
50
|
-
if debug_lines:
|
|
51
|
-
print("✅ 发现DEBUG级别的运行模式信息:")
|
|
52
|
-
for line in debug_lines:
|
|
53
|
-
print(f" {line}")
|
|
54
|
-
else:
|
|
55
|
-
print("❌ 没有发现DEBUG级别的运行模式信息")
|
|
56
|
-
|
|
57
|
-
print("\n所有日志内容:")
|
|
58
|
-
lines = content.split('\n')
|
|
59
|
-
for i, line in enumerate(lines, 1):
|
|
60
|
-
if line.strip():
|
|
61
|
-
print(f"{i:3d}: {line}")
|
|
62
|
-
else:
|
|
63
|
-
print("❌ 日志文件未创建")
|
|
64
|
-
|
|
65
|
-
except Exception as e:
|
|
66
|
-
print(f"错误: {e}")
|
|
67
|
-
import traceback
|
|
68
|
-
traceback.print_exc()
|
|
69
|
-
|
|
70
|
-
print("=== 测试完成 ===")
|
|
71
|
-
|
|
72
|
-
if __name__ == "__main__":
|
|
73
|
-
test_mode_log_level()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|