change settings middleware name and updating middleware template

This commit is contained in:
muriloviana 2016-10-19 00:37:31 -02:00
parent d5bd44a5b9
commit 34f2014c55
4 changed files with 41 additions and 25 deletions

View File

@ -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')

View File

@ -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

View File

@ -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 doesnt have a response associated.
# Must return only requests (not items).
pass

View File

@ -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