Scrapy, a fast high-level web crawling & scraping framework for Python.
extended documentation on how to access crawler stats from extensions
Pablo Hoffman8f4c879b58ab
diff --git a/docs/topics/stats.rst b/docs/topics/stats.rstindex 2412d0e4b..d0dcc9f5e 100644--- a/docs/topics/stats.rst+++ b/docs/topics/stats.rst@@ -29,12 +29,17 @@ opened when the spider is opened, and closed when the spider is closed.Common Stats Collector uses===========================-Access the stats collector throught the :attr:`~scrapy.crawler.Crawler.stats`-attribute::+Access the stats collector through the :attr:`~scrapy.crawler.Crawler.stats`+attribute. Here is an example of an extension that access stats::- @classmethod- def from_crawler(cls, crawler):- stats = crawler.stats+ class ExtensionThatAccessStats(object):++ def __init__(self, stats):+ self.stats = stats++ @classmethod+ def from_crawler(cls, crawler):+ return cls(crawler.stats)Set stat value::