【问题标题】:How to pass multiple arguments to Scrapy spider (getting error running 'scrapy crawl' with more than one spider is no longer supported)?如何将多个参数传递给 Scrapy 蜘蛛(不再支持使用多个蜘蛛运行 'scrapy crawl' 时出错)?
【发布时间】:2015-09-08 21:53:50
【问题描述】:

我想将多个用户定义的参数传递给我的scrapy spyder,所以我尝试关注这个帖子:How to pass a user defined argument in scrapy spider

但是,当我按照那里的建议进行操作时,出现错误:

root@ scrapy crawl dmoz -a address= 40-18 48th st -a borough=4
Usage
=====
  scrapy crawl [options] <spider>

crawl: error: running 'scrapy crawl' with more than one spider is no longer supported

我还尝试了各种引号排列:

root@ scrapy crawl dmoz -a address= "40-18 48th st" -a borough="4"
Usage
=====
  scrapy crawl [options] <spider>
crawl: error: running 'scrapy crawl' with more than one spider is no longer supported

将参数传递给 Scrapy 蜘蛛的正确方法是什么?我想为蜘蛛的登录/抓取过程传递用户名和密码。感谢您的任何建议。

【问题讨论】:

    标签: python scrapy


    【解决方案1】:

    我猜没有scrapy 问题。这就是您的shell 解释输入、在空格中分割标记的方式。所以,你不能在键和它的值之间有任何它们。尝试:

    scrapy crawl dmoz -a address="40-18 48th st" -a borough="4"
    

    【讨论】:

    • 我也尝试过这个选项。我正在使用 Ubuntu,以防万一,但我已经尝试了输入和输入名称上引号的所有排列。除非我遗漏了什么,否则您的建议正是我在问题结尾处所提供的作为我已经尝试过的示例?
    • @sunny:确定您尝试了我的解决方案,但也没有用?这不一样。 -a 开关接受key=value 参数,但shell 处理scrapy 之前的输入,= 符号之后的空格使其生成两个不同的标记,scrapy 解释为另一个蜘蛛。
    • 我刚刚复制并粘贴了您的行,它给了我与上面粘贴的完全相同的错误。
    • @sunny:那么,对不起。我用同样的错误测试了你的,我的也成功了,所以我无法提供更多帮助,因为无法重现你的问题。
    • 非常感谢。我真的很感谢你的帮助。我会尝试重新启动,但这在 Linux 上通常并不重要。我认为你是对的,它一定是一个 shell 问题,所以我会这样指出我的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多