Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

stats: limit the default number of stats history to 10

Daniel Grana570f49d40719
diff --git a/scrapy/trunk/scrapy/command/commands/stats.py b/scrapy/trunk/scrapy/command/commands/stats.py
index e062ce6a8..1b0febb75 100644
--- a/scrapy/trunk/scrapy/command/commands/stats.py
+++ b/scrapy/trunk/scrapy/command/commands/stats.py
@@ -12,11 +12,13 @@ class Command(ScrapyCommand):
def add_options(self, parser):
ScrapyCommand.add_options(self, parser)
parser.add_option("-p", "--path", dest="path", help="restrict stats to PATH", metavar="PATH")
+ parser.add_option("--limit", dest="limit", default='10', help="limit the number of stats")
def run(self, args, opts):
if not args:
print "A domain is required"
return
+
if not settings['SCRAPING_DB']:
print "SCRAPING_DB setting is required for this command"
return
@@ -26,5 +28,5 @@ class Command(ScrapyCommand):
for domain in args:
print "# %s" % domain
- pprint.pprint(list(ddh.getall(domain, opts.path)))
+ pprint.pprint(list(ddh.get(domain, path=opts.path, count=int(opts.limit))))