【发布时间】:2014-09-23 02:43:09
【问题描述】:
我有一个包含多个蜘蛛的 Scrapy 项目。该项目托管在一个 scrapyd 实例上。 我希望能够动态更改项目 settings.py 文件中的设置(例如 DOWNLOADER_MIDDLEWARES)。
是否可以在向 scrapyd 实例发送请求时更改这些设置。请注意,我不想创建多个项目,因为这将导致跨项目重复公共代码。
谢谢
【问题讨论】:
我有一个包含多个蜘蛛的 Scrapy 项目。该项目托管在一个 scrapyd 实例上。 我希望能够动态更改项目 settings.py 文件中的设置(例如 DOWNLOADER_MIDDLEWARES)。
是否可以在向 scrapyd 实例发送请求时更改这些设置。请注意,我不想创建多个项目,因为这将导致跨项目重复公共代码。
谢谢
【问题讨论】:
您可以将参数传递给 scrapyd 并使用 -d 参数更改设置
curl http://localhost:6800/schedule.json -d project=myproject -d spider=somespider -d setting=DOWNLOAD_DELAY=2 -d arg1=val1
【讨论】:
curl http://localhost:6800/schedule.json -d project=GenericCrawl -d spider=Generic -d "setting=ITEM_PIPELINES={'GenericCrawl.pipelines.DefaultValuesPipeline': 299,'GenericCrawl.pipelines.MySQL':300}" ,但收到以下错误[Launcher,4746/stderr] dictionary update sequence element #0 has length 1; 2 is required