Search code examples
scrapyspidermon

Scrapy spidermon exceptions


I'm trying to setup the basic suite of spidermon monitors as described here I did a quick Google search and also found this. So I made a quick monitors.py, then copy and pasted the code in there.

I then proceeded to do this:

SPIDERMON_ENABLED = True

SPIDERMON_SPIDER_CLOSE_MONITORS = (
    'spidermon.contrib.scrapy.monitors.SpiderCloseMonitorSuite',
)

in my settings.py in the scrapy project.

It keeps raising this error:

spidermon.exceptions.NotConfigured: You should specify a minimum number of items to check against

Which I believe I've done (SPIDERMON_MIN_ITEMS = 10 # "SPIDERMON_MIN_ITEMS" - at the top of the file).

What am I doing wrong? I just want to setup the pre-defined monitors and then optimize them later.


Solution

  • Spidermon couldn't find a valid value for SPIDERMON_MIN_ITEMS in the settings. This must be an integer value bigger than zero otherwise it'll throw the error described. SPIDERMON_ADD_FIELD_COVERAGE set is also mandatory in order to use all the monitors available in this MonitorSuite.

    In order to run the built-in close MonitorSuite SpiderCloseMonitorSuite from Spidermon project, please confirm if the settings.py file - located in the root directory of your scrapy project - have the variables below:

    EXTENSIONS = {
       'spidermon.contrib.scrapy.extensions.Spidermon': 500,
    }
    
    SPIDERMON_ENABLED = True
    
    SPIDERMON_MIN_ITEMS = 10
    SPIDERMON_ADD_FIELD_COVERAGE = True
    
    SPIDERMON_SPIDER_CLOSE_MONITORS = (
        'spidermon.contrib.scrapy.monitors.SpiderCloseMonitorSuite',
    )