Feapder
Overview
Implement feapder 1.9.2 code with the framework's native patterns, grounded in the vendored docs, templates, tests, and source anchors. Choose the right spider base class first, then follow the matching startup, request, parse, persistence, and debugging patterns.
Workflow Decision Tree
- Classify the request before writing code:
- Use
AirSpiderfor small, local, non-distributed jobs. - Use
Spiderfor Redis-backed distributed crawling, resumable queues, and automatic item persistence. - Use
TaskSpiderwhen seeds come from MySQL or Redis task tables and the framework should manage seed loading. - Use
BatchSpiderfor periodic batches with batch records and explicit task-state transitions.
- Use
- Read only the reference file that matches the task:
- Spider selection, CLI scaffolding, and project layout: references/spider-types-and-scaffolding.md
- Code patterns for request flow, items, task updates, and render usage: references/code-patterns.md
- Settings, pipelines, shell debugging, and upstream source anchors: references/settings-debugging-and-sources.md
- Open vendored docs, tests, or source files only for the specific behavior being implemented or verified. Do not bulk-read
references/vendor/.
- Reuse feapder conventions instead of inventing abstractions:
- Import
feapderdirectly and subclass the correct base spider. - Emit work with
yield feapder.Request(...). - Keep parsing in
parseor explicit callback methods passed throughcallback=.... - Prefer
__custom_setting__for spider-local overrides andsetting.pyfor project-wide config. - Prefer
from feapder.utils.log import logandlog.info(...)for runtime logs instead ofprint(...)unless the user explicitly asks to mirror upstream demo output. - Match the surrounding project's language for logs and comments. If creating a new standalone demo for a Chinese request, concise Chinese logs and comments are acceptable.
- Import
- If the user asks to create new feapder code, prefer the framework's generated structure and naming conventions over bespoke layouts.
- If the user asks for a simple crawler demo and does not mention persistence,
Item,UpdateItem, pipeline wiring, Redis, MySQL, task tables, batch scheduling, distributed workers, or multi-file output, default to the single-fileAirSpiderstyle shown in references/vendor/feapder-1.9.2/tests/air-spider/test_air_spider.py: one file, one spider class, minimal startup block, and only the code required to demonstrate the requested behavior.
Working Rules
- Keep output aligned with feapder 1.9.2, not newer community variants.
- Prefer minimal, working spider code over framework-agnostic architecture.
- When the request is underspecified, do not scaffold a full feapder project by default. Write the smallest single-file
AirSpiderdemo only for pure crawling or parsing requests. If the request mentionsItem,UpdateItem, 入库,ITEM_PIPELINES, Redis, MySQL, task tables, or batch/task state, choose the corresponding spider and project shape instead. - When modifying an existing feapder project, preserve its current spider type,
main.pydispatch style, item modules, andsetting.pyshape unless the user asks for a migration. - When persistence is needed, decide explicitly between:
- Manual DB calls with
MysqlDBorRedisDB - Automatic batch persistence via
ItemorUpdateItem - Custom
ITEM_PIPELINES
- Manual DB calls with
- When render is required, set
render=Trueon the request and then align downloader configuration with the project'ssetting.pyor__custom_setting__. - When handling
BatchSpiderorTaskSpider, treat master and worker entrypoints separately. Do not collapse them into a single ambiguous startup path. - When writing new spider code, prefer
log.info(...),log.error(...), and similar logger methods for runtime output. Avoidprint(...)unless the user explicitly asks for raw console prints or exact upstream reproduction. - Keep log and comment language consistent with the existing project. For net-new standalone demos requested in Chinese, concise Chinese logs such as
log.info(f"第{request.page}页原始结果 | {response.json}")are acceptable. - Only keep comments that clarify non-obvious logic, and avoid introducing mixed-language diffs unless the user asks for a language change.
Implementation Checklist
Before finishing a feapder task, verify the code against this checklist:
- The spider inherits the correct feapder base class.
- If the task is a pure crawling or parsing demo and does not require persistence or task orchestration, the new spider defaults to the single-file
AirSpiderpattern anchored byreferences/vendor/feapder-1.9.2/tests/air-spider/test_air_spider.py. - Startup code passes the required constructor args such as
redis_key,task_table,task_keys, or batch metadata when needed. - Request callbacks, carried parameters, and middleware hooks use feapder's expected method signatures.
- Distributed spiders update task state where required instead of relying on implicit completion.
- Item, pipeline, and setting references match the project's existing module layout.
- Debugging guidance uses feapder-native tools such as
feapder shell,to_DebugSpider, orto_DebugBatchSpiderwhen appropriate. - New example code keeps log and comment language aligned with the surrounding project, or with the user's requested language for standalone demos.
Source Anchors
Use the vendored feapder 1.9.2 snapshot under references/vendor/ as the source of truth. This keeps the skill portable when copied to another machine. Prefer the smallest relevant doc or test first, then open source files only when you need to confirm method signatures or edge-case behavior:
- Core overview: references/vendor/feapder-1.9.2/README.md
- Usage docs: references/vendor/feapder-1.9.2/docs/usage/AirSpider.md, references/vendor/feapder-1.9.2/docs/usage/Spider.md, references/vendor/feapder-1.9.2/docs/usage/TaskSpider.md, references/vendor/feapder-1.9.2/docs/usage/BatchSpider.md
- CLI and project generation: references/vendor/feapder-1.9.2/docs/command/cmdline.md
- Minimal runnable examples: references/vendor/feapder-1.9.2/tests/air-spider/test_air_spider.py, references/vendor/feapder-1.9.2/tests/spider/spiders/test_spider.py, references/vendor/feapder-1.9.2/tests/batch-spider/spiders/test_spider.py, references/vendor/feapder-1.9.2/tests/test-pipeline/pipeline.py