mirror of https://github.com/scrapy/scrapy.git
change settings middleware name and updating middleware template
This commit is contained in:
parent
d5bd44a5b9
commit
34f2014c55
|
|
@ -17,7 +17,7 @@ TEMPLATES_TO_RENDER = (
|
|||
('${project_name}', 'settings.py.tmpl'),
|
||||
('${project_name}', 'items.py.tmpl'),
|
||||
('${project_name}', 'pipelines.py.tmpl'),
|
||||
('${project_name}', 'middleware.py.tmpl'),
|
||||
('${project_name}', 'middlewares.py.tmpl'),
|
||||
)
|
||||
|
||||
IGNORE = ignore_patterns('*.pyc', '.svn')
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Define here the models for your spider middleware
|
||||
#
|
||||
# See documentation in:
|
||||
# http://doc.scrapy.org/en/latest/topics/spider-middleware.html
|
||||
|
||||
|
||||
class ${ProjectName}SpiderMiddleware(object):
|
||||
# This method is called for each response that goes through the
|
||||
# spider middleware and into the spider, for processing.
|
||||
|
||||
def process_spider_input(response, spider):
|
||||
# Called for each response that goes to spider
|
||||
pass
|
||||
|
||||
def process_spider_output(response, result, spider):
|
||||
# Called for each response with the spider results
|
||||
pass
|
||||
|
||||
def process_spider_exception(response, exception, spider):
|
||||
# Called whenever a spider raises an exception
|
||||
pass
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Define here the models for your spider middleware
|
||||
#
|
||||
# See documentation in:
|
||||
# http://doc.scrapy.org/en/latest/topics/spider-middleware.html
|
||||
|
||||
|
||||
class ${ProjectName}SpiderMiddleware(object):
|
||||
|
||||
def process_spider_input(response, spider):
|
||||
# Called for each response that goes through the spider
|
||||
# middleware and into the spider.
|
||||
|
||||
# Should return None or raise an exception.
|
||||
pass
|
||||
|
||||
def process_spider_output(response, result, spider):
|
||||
# Called with the results returned from the Spider, after
|
||||
# it has processed the response.
|
||||
|
||||
# Must return an iterable of Request, dict or Item objects.
|
||||
pass
|
||||
|
||||
def process_spider_exception(response, exception, spider):
|
||||
# Called when a spider or process_spider_input() method
|
||||
# (from other spider middleware) raises an exception.
|
||||
|
||||
# Should return either None or an iterable of Response, dict
|
||||
# or Item objects.
|
||||
pass
|
||||
|
||||
def process_start_requests(start_requests, spider):
|
||||
# Called with the start requests of the spider, and works
|
||||
# similarly to the process_spider_output() method, except
|
||||
# that it doesn’t have a response associated.
|
||||
|
||||
# Must return only requests (not items).
|
||||
pass
|
||||
|
|
@ -47,7 +47,7 @@ ROBOTSTXT_OBEY = True
|
|||
# Enable or disable spider middlewares
|
||||
# See http://scrapy.readthedocs.org/en/latest/topics/spider-middleware.html
|
||||
#SPIDER_MIDDLEWARES = {
|
||||
# '$project_name.middlewares.MyCustomSpiderMiddleware': 543,
|
||||
# '$project_name.middlewares.${ProjectName}SpiderMiddleware': 543,
|
||||
#}
|
||||
|
||||
# Enable or disable downloader middlewares
|
||||
|
|
|
|||
Loading…
Reference in New Issue