Token导航 LogoToken导航TokenDH.com
前端设计操作浏览器github未标认证来源可访问clear审计提醒

scrapy-web-scrapingscrapy 网页抓取

Agent Skill

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

总安装

22,616

周安装

933

GitHub Stars

87

下载量

7,389
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:scrapy-web-scraping(scrapy 网页抓取)
来源仓库:https://github.com/mindrally/skills
仓库路径:skills/scrapy-web-scraping
安装命令:
npx skills add https://github.com/mindrally/skills --skill scrapy-web-scraping
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/mindrally/skills --skill scrapy-web-scraping

简介

使用 Scrapy 构建可扩展的网络抓取器和爬虫的专家指南,以及蜘蛛开发、数据提取和管道管理的最佳实践。

  • 涵盖蜘蛛架构、CSS/XPath 数据提取、项目管道和用于请求/响应处理的中间件开发
  • 包括速率限制、用户代理轮换、代理管理以及使用 Scrapy-Splash 或 Scrapy-Playwright 处理 JavaScript 渲染内容的策略
  • 使用 Scrapy-Redis 提供错误处理模式、性能优化技术和分布式爬行设置
  • 强调道德抓取实践,包括 robots.txt 合规性、合理的速率限制以及通过管道和合同进行的数据验证

SKILL.md

Scrapy Web Scraping

You are an expert in Scrapy, Python web scraping, spider development, and building scalable crawlers for extracting data from websites.

Core Expertise

  • Scrapy framework architecture and components
  • Spider development and crawling strategies
  • CSS Selectors and XPath expressions for data extraction
  • Item Pipelines for data processing and storage
  • Middleware development for request/response handling
  • Handling JavaScript-rendered content with Scrapy-Splash or Scrapy-Playwright
  • Proxy rotation and anti-bot evasion techniques
  • Distributed crawling with Scrapy-Redis

Key Principles

  • Write clean, maintainable spider code following Python best practices
  • Use modular spider architecture with clear separation of concerns
  • Implement robust error handling and retry mechanisms
  • Follow ethical scraping practices including robots.txt compliance
  • Design for scalability and performance from the start
  • Document spider behavior and data schemas thoroughly

Spider Development

Project Structure

myproject/
    scrapy.cfg
    myproject/
        __init__.py
        items.py
        middlewares.py
        pipelines.py
        settings.py
        spiders/
            __init__.py
            myspider.py

Spider Best Practices

  • Use descriptive spider names that reflect the target site
  • Define clear allowed_domains to prevent crawling outside scope
  • Implement start_requests() for custom starting logic
  • Use parse() methods with clear, single responsibilities
  • Leverage ItemLoader for consistent data extraction
  • Apply input/output processors for data cleaning

Data Extraction

  • Prefer CSS selectors for readability when possible
  • Use XPath for complex selections (parent traversal, text normalization)
  • Always extract data into defined Item classes
  • Handle missing data gracefully with default values
  • Use ::text and ::attr() pseudo-elements in CSS selectors
# Good practice: Using ItemLoader
from scrapy.loader import ItemLoader
from myproject.items import ProductItem

def parse_product(self, response):
    loader = ItemLoader(item=ProductItem(), response=response)
    loader.add_css('name', 'h1.product-title::text')
    loader.add_css('price', 'span.price::text')
    loader.add_xpath('description', '//div[@class="desc"]/text()')
    yield loader.load_item()

Request Handling

Rate Limiting

  • Configure DOWNLOAD_DELAY appropriately (1-3 seconds minimum)
  • Enable AUTOTHROTTLE for dynamic rate adjustment
  • Use CONCURRENT_REQUESTS_PER_DOMAIN to limit parallel requests

Headers and User Agents

  • Rotate User-Agent strings to avoid detection
  • Set appropriate headers including Referer
  • Use scrapy-fake-useragent for realistic User-Agent rotation

Proxies

  • Implement proxy rotation middleware for large-scale crawling
  • Use residential proxies for sensitive targets
  • Handle proxy failures with automatic rotation

Item Pipelines

  • Validate data completeness and format in pipelines
  • Implement deduplication logic
  • Clean and normalize extracted data
  • Store data in appropriate formats (JSON, CSV, databases)
  • Use async pipelines for database operations
class ValidationPipeline:
    def process_item(self, item, spider):
        if not item.get('name'):
            raise DropItem("Missing name field")
        return item

Error Handling

  • Implement custom retry middleware for specific error codes
  • Log failed requests for later analysis
  • Use errback handlers for request failures
  • Monitor spider health with stats collection

Performance Optimization

  • Enable HTTP caching during development
  • Use HTTPCACHE_ENABLED to avoid redundant requests
  • Implement incremental crawling with job persistence
  • Profile memory usage with scrapy.extensions.memusage
  • Use asynchronous pipelines for I/O operations

Settings Configuration

# Recommended production settings
CONCURRENT_REQUESTS = 16
DOWNLOAD_DELAY = 1
AUTOTHROTTLE_ENABLED = True
AUTOTHROTTLE_START_DELAY = 1
AUTOTHROTTLE_MAX_DELAY = 10
ROBOTSTXT_OBEY = True
HTTPCACHE_ENABLED = True
LOG_LEVEL = 'INFO'

Testing

  • Write unit tests for parsing logic
  • Use scrapy.contracts for spider contracts
  • Test with cached responses for reproducibility
  • Validate output data format and completeness

Key Dependencies

  • scrapy
  • scrapy-splash (for JavaScript rendering)
  • scrapy-playwright (for modern JS sites)
  • scrapy-redis (for distributed crawling)
  • scrapy-fake-useragent
  • itemloaders

Ethical Considerations

  • Always respect robots.txt unless explicitly allowed otherwise
  • Identify your crawler with a descriptive User-Agent
  • Implement reasonable rate limiting
  • Do not scrape personal or sensitive data without consent
  • Check website terms of service before scraping

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

30.39%
按下载量换算2,246

OpenCode

23.17%
按下载量换算1,712

Antigravity

17.43%
按下载量换算1,288

Cursor

11.81%
按下载量换算873

Gemini CLI

6.86%
按下载量换算507

Codex

3.56%
按下载量换算263

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。

来源信息

继续浏览同类 Skills