部署Scrapy项目到远程Scrapyd服务报错

Deploy Scrapy project to remote Scrapyd service error

我尝试将一个测试 Scrapy 项目部署到远程 Scrapyd 服务器。我在客户端收到以下错误消息。

curl http://IP:6800/addversion.json -d project=test_project -d spider=quotes
{"status": "error", "message": "'version'", "node_name": "serverName"}

服务器端错误消息

2018-11-13T12:22:22+0000 [_GenericHTTPChannelProtocol,0,IP Address] Unhandled Error
    Traceback (most recent call last):
      File "/usr/lib64/python2.7/site-packages/twisted/web/http.py", line 2190, in allContentReceived
        req.requestReceived(command, path, version)
      File "/usr/lib64/python2.7/site-packages/twisted/web/http.py", line 917, in requestReceived
        self.process()
      File "/usr/lib64/python2.7/site-packages/twisted/web/server.py", line 199, in process
        self.render(resrc)
      File "/usr/lib64/python2.7/site-packages/twisted/web/server.py", line 259, in render
        body = resrc.render(self)
    --- <exception caught here> ---
      File "/usr/lib/python2.7/site-packages/scrapyd/webservice.py", line 21, in render
        return JsonResource.render(self, txrequest).encode('utf-8')
      File "/usr/lib/python2.7/site-packages/scrapyd/utils.py", line 20, in render
        r = resource.Resource.render(self, txrequest)
      File "/usr/lib64/python2.7/site-packages/twisted/web/resource.py", line 250, in render
        return m(request)
      File "/usr/lib/python2.7/site-packages/scrapyd/webservice.py", line 83, in render_POST
        version = txrequest.args[b'version'][0].decode('utf-8')
    exceptions.KeyError: 'version'

我检查了客户端和服务端,Scrapy版本都是1.5.1。 python 版本是 2.7.*

您之前显示的示例 curl 命令不应该起作用。根据 the documentation,您还需要:

  1. 一个 version 参数,这被认为是您现在遇到的问题的原因。
  2. 一个egg参数包含实际的项目代码,否则当你只传入项目名称和蜘蛛名称时scrapyd将无法接收它。