Scrapy, a fast high-level web crawling & scraping framework for Python.
Rule.process_request: use scrapy.utils.python.get_func_args
Eugenio Lacuestabbf24b7a1ce2
diff --git a/scrapy/spiders/crawl.py b/scrapy/spiders/crawl.pyindex c01f75798..f474b0a18 100644--- a/scrapy/spiders/crawl.py+++ b/scrapy/spiders/crawl.py@@ -10,6 +10,7 @@ import sixfrom scrapy.http import Request, HtmlResponsefrom scrapy.utils.spider import iterate_spider_output+from scrapy.utils.python import get_func_argsfrom scrapy.spiders import Spider@@ -35,10 +36,8 @@ class Rule(object):Wrapper around the request processing function to maintain backward compatibilitywith functions that do not take a Response object as parameter."""- argcount = self.process_request.__code__.co_argcount- if hasattr(self.process_request, '__self__'):- argcount = argcount - 1- args = [request] if argcount == 1 else [request, response]+ arg_count = len(get_func_args(self.process_request))+ args = [request] if arg_count == 1 else [request, response]return self.process_request(*args)