scrapy-web-scraping
Skill266 starsChanged 10 months agoApache-2.0View on GitHub
Expert guidance for building web scrapers and crawlers using the Scrapy Python framework with best practices for spider development, data extraction, and pipeline management.
In this repository264 other files it gives its agents.
- accessibility-a11ySkill
- alpine-jsSkill
- analytics-data-analysisSkill
- android-developmentSkill
- angular-developmentSkill
- angularSkill
- anime-jsSkill
- anthropic-claude-developmentSkill
- api-developmentSkill
- apollo-graphqlSkill
- aspnet-coreSkill
- astroSkill
- auth0-authenticationSkill
- autogen-developmentSkill
- automl-hyperparameter-optimizationSkill
- aws-developmentSkill
- azureSkill
- backend-developmentSkill
- bash-scriptingSkill
- beautifulsoup-parsingSkill
- bitbucket-workflowSkill
- blazorSkill
- blender-python-addonSkill
- blockchainSkill
- bootstrapSkill
- business-central-developmentSkill
- cheerio-parsingSkill
- chrome-extension-developmentSkill
- ci-cd-best-practicesSkill
- clean-architectureSkill
- clean-codeSkill
- clerk-authenticationSkill
- cloudflare-developmentSkill
- computer-vision-opencvSkill
- convexSkill
- cppSkill
- c-sharpSkill
- cssSkill
- cypressSkill
- data-analysis-jupyterSkill
- data-analystSkill
- data-jupyter-pythonSkill
- deep-learning-pythonSkill
- deep-learning-pytorchSkill
- deep-learningSkill
- deno-typescriptSkill
- design-systemsSkill
- devopsSkill
- django-pythonSkill
- django-rest-api-developmentSkill
- dockerSkill
- dotnetSkill
- drizzle-ormSkill
- drupal-developmentSkill
- elasticsearch-best-practicesSkill
- electron-developmentSkill
- elixirSkill
- embedded-stm32Skill
- esbuild-bundlerSkill
- ethereumSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
23 rules. About 0 are common, 16 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈16
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 22
Write clean, maintainable spider code following Python best practices
- Distinctive: line 23
Use modular spider architecture with clear separation of concerns
- Distinctive: line 25
Follow ethical scraping practices including robots.txt compliance
- Distinctive: line 27
Document spider behavior and data schemas thoroughly
- Distinctive: line 48
Use descriptive spider names that reflect the target site
- Very specific: line 51
Use parse() methods with clear, single responsibilities
- Distinctive: line 57
Prefer CSS selectors for readability when possible
- Distinctive: line 58
Use XPath for complex selections (parent traversal, text normalization)
- Distinctive: line 59
Always extract data into defined Item classes
- Very specific: line 61
Use ::text and ::attr() pseudo-elements in CSS selectors
- Very specific: line 81
Use CONCURRENT_REQUESTS_PER_DOMAIN to limit parallel requests
- Very specific: line 86
Use scrapy-fake-useragent for realistic User-Agent rotation
- Distinctive: line 90
Use residential proxies for sensitive targets
- Distinctive: line 99
Use async pipelines for database operations
- Very specific: line 113
Use errback handlers for request failures
- Very specific: line 119
Use HTTPCACHE_ENABLED to avoid redundant requests
- Distinctive: line 122
Use asynchronous pipelines for I/O operations
- Distinctive: line 140
Write unit tests for parsing logic
- Very specific: line 141
Use scrapy.contracts for spider contracts
- Distinctive: line 142
Test with cached responses for reproducibility
- Distinctive: line 156
Always respect robots.txt unless explicitly allowed otherwise
- Distinctive: line 159
Do not scrape personal or sensitive data without consent
- Distinctive: line 160
Check website terms of service before scraping
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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.pySpider Best Practices
- Use descriptive spider names that reflect the target site
- Define clear
allowed_domainsto prevent crawling outside scope - Implement
start_requests()for custom starting logic - Use
parse()methods with clear, single responsibilities - Leverage
ItemLoaderfor 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
::textand::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_DELAYappropriately (1-3 seconds minimum) - Enable
AUTOTHROTTLEfor dynamic rate adjustment - Use
CONCURRENT_REQUESTS_PER_DOMAINto limit parallel requests
Headers and User Agents
- Rotate User-Agent strings to avoid detection
- Set appropriate headers including Referer
- Use
scrapy-fake-useragentfor 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 itemError Handling
- Implement custom retry middleware for specific error codes
- Log failed requests for later analysis
- Use
errbackhandlers for request failures - Monitor spider health with stats collection
Performance Optimization
- Enable HTTP caching during development
- Use
HTTPCACHE_ENABLEDto 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.contractsfor 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
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

