我正在尝试将使用 slyd 创建的蜘蛛配置为使用scrapy-elasticsearch,所以我发送-d parameter=value
配置它:
curl http://localhost:6800/schedule.json -d project=myproject -d spider=myspider -d setting=CLOSESPIDER_ITEMCOUNT=100 -d settings=ITEM_PIPELINE=scrapyelasticsearch.ElasticSearchPipeline -d setting=ELASTICSEARCH_SERVER=localhost -d setting=ELASTICSEARCH_PORT=9200 -d setting=ELASTICSEARCH_INDEX=scrapy -d setting=ELASTICSEARCH_TYPE=items -d setting=ELASTICSEARCH_UNIQ_KEY=url
这是应该进入 settings.py 的默认配置:
ITEM_PIPELINES = [
'scrapyelasticsearch.ElasticSearchPipeline',
]
ELASTICSEARCH_SERVER = 'localhost' # If not 'localhost' prepend 'http://'
ELASTICSEARCH_PORT = 9200 # If port 80 leave blank
ELASTICSEARCH_USERNAME = ''
ELASTICSEARCH_PASSWORD = ''
ELASTICSEARCH_INDEX = 'scrapy'
ELASTICSEARCH_TYPE = 'items'
ELASTICSEARCH_UNIQ_KEY = 'url'
我还没有找到一种方法来配置 slyd 以使用每个新蜘蛛自动生成这些设置,所以我试图将选项作为-d
参数传递。scrapyd 仍然运行蜘蛛,但没有保存到 elasticsearch,错误日志显示如下:
[Launcher,1900/stderr] /home/PORTIA/local/lib/python2.7/site-packages/scrapy/contrib/pipeline/__init__.py:21:
ScrapyDeprecationWarning: ITEM_PIPELINES defined as a list or a set is deprecated, switch to a dict
category=ScrapyDeprecationWarning, stacklevel=1)