title: Where and how to print scrapy stats upon spider_closed signal (finish)?
body: <p>I have a working <em>BaseSpider</em> on Scrapy <strong>0.20.0</strong>. But I'm trying to collect the number of found website URL's and print it as INFO when the spider is finished (closed). Problem is that I am not able to print this simple integer variable at the <em>end of the session</em>, and any print statement in the <code>parse()</code> or <code>parse_item()</code> functions are printed too early, long before. </p>
  
  <p>I also looked at <a href="https://stackoverflow.com/questions/12394184/scrapy-call-a-function-when-a-spider-quits">this</a> question, but it seem somewhat outdated and it is unclear how to use it, properly. I.e. Where to put it (myspider.py, pipelines.py etc)?</p>
  
  <p>Right now my spider-code is something like:</p>
  
  <pre><code>class MySpider(BaseSpider):
  ...
  foundWebsites = 0
  ...
  def parse(self, response):
      ...
      print "Found %d websites in this session.\n\n" % (self.foundWebsites)
  
  def parse_item(self, response):
      ...
      if item['website']:
          self.foundWebsites += 1
      ...
  </code></pre>
  
  <p>And this is obviously not working as intended. Any better and simple ideas?   </p>