Setup
Install
pip install scrapy-poet
Enable
Configure the scrapy-poet add-on to enable it:
settings.py
ADDONS = {
"scrapy_poet.Addon": 300,
}
This is what the add-on changes:
-
Sets
InjectionMiddlewarewith value543.Sets
HtmlMetadataMiddlewarewith value585.Replaces
scrapy.downloadermiddlewares.stats.DownloaderStatswithscrapy_poet.DownloaderStatsMiddleware.
Sets
REQUEST_FINGERPRINTER_CLASStoScrapyPoetRequestFingerprinter.In
SPIDER_MIDDLEWARES, setsRetryMiddlewarewith value275.
Configure
Declare the SCRAPY_POET_DISCOVER setting with a list of modules that
define page objects, so that they can be loaded at run-time.
A best practice is to create a pages/ folder in your Scrapy project, a
sibling of your spiders/ folder, add an empty __init__.py file to it
to make it a Python module, and declare its import path in the setting:
settings.py
SCRAPY_POET_DISCOVER = ["myproject.pages"]