无法识别 windows scrapyd-deploy [英] windows scrapyd-deploy is not recognized

查看:133
本文介绍了无法识别 windows scrapyd-deploy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经像这样安装了scrapyd

I have install the scrapyd like this

pip install scrapyd

我想使用scrapyd-deploy

I want to use scrapyd-deploy

当我输入scrapyd时

when i type scrapyd

我在 cmd 中遇到此异常:

i got this exception in cmd:

'scrapyd' 不是内部或外部命令,也不是可运行的程序或批处理文件.

'scrapyd' is not recognized as an internal or external command, operable program or batch file.

推荐答案

我遇到了同样的问题,我也读到了一些关于scrapyd不可用/不能在windows上运行的意见,差点放弃了(没有并不是真的需要它,因为我打算部署到 linux 机器上,想要在 windows 上使用 scrapyd 进行调试).然而,经过一番研究,我找到了一种方法.由于我还没有找到任何明确的说明,我会尽量让我的答案尽可能详细,列出所有对我有用的步骤.

I ran into the same issue, and I also read some opinions that scrapyd isn't available / can't run on windows and nearly gave it up (didn't really need it as I intend on deploying to a linux machine, wanted scrapyd on windows for debug purposes). However, after some research I found a way. As I haven't found any clear instructions on this, I will try to make my answer as detailed as possible, listing all the steps that worked for me.

假设你想在本地机器上运行scrapyd,你需要运行两个命令行:第一个用于连接scrapyd并保持连接打开,第二个用于部署和调度.

Assuming you want to run scrapyd on your local machine, you will need two command lines running: The first is used to connect to scrapyd and keeping the connection open, and the second is for deploying and scheduling.

  • 您已经通过pip安装了scrapyd.

  • You already pip installed scrapyd.

在该文件夹中创建一个文件夹 C:\scrapyd 和一个名为 scrapyd.log 的空 .log 文件(不确定这一步是否必要).

Create a folder C:\scrapyd and an empty .log file named scrapyd.log in this folder (not sure this step is necessary).

打开 cmd 和 cd 到 Python 中的 Scripts 文件夹.这通常类似于:C:\Python27\Scripts.类型:python scrapyd

Open your cmd and cd to your Scripts folder inside Python. This is usually something like: C:\Python27\Scripts. Type: python scrapyd

此时您应该会看到类似这样的内容:

At this point you should see something like that:

2014-03-26 13:57:30+0200 [-] Log opened.

2014-03-26 13:57:30+0200 [-] twistd 13.2.0 (C:\Python27\python.exe 2.7.6) starting up.

2014-03-26 13:57:30+0200 [-] reactor class: twisted.internet.selectreactor.SelectReactor.

2014-03-26 13:57:30+0200 [-] Site starting on 6800

2014-03-26 13:57:30+0200 [-] Starting factory <twisted.web.server.Site instance at 0x0000000003F69208>

2014-03-26 13:57:30+0200 [Launcher] Scrapyd 1.0.1 started: max_proc=16, runner='scrapyd.runner'

  • 如果您可以打开浏览器并转到 http://localhost:6800 就可以了.命令行窗口应在后台保持打开状态,因为如果您关闭它,连接将被关闭.

  • If you can open your browser and go to http://localhost:6800 then you're ok. The command line window should stay open in the background as connection will be closed if you'll close it.

    在 Windows 资源管理器上导航到您的 scrapy 项目文件夹并编辑在那里找到的 scrapy.cfg 文件:例如写下您的部署目标名称:[deploy:scrapyd],然后取消注释 url 行.

    On windows explorer navigate to your scrapy project folder and edit the scrapy.cfg file found there: write your deploy target name: [deploy:scrapyd] for instance, and uncomment the url line.

    打开第二个命令行并 cd 到您的 scrapy 项目文件夹.输入:scrapy deploy -l

    Open a second command line and cd to your scrapy project folder. Type: scrapy deploy -l

    部署:输入:scrapy deploy scrapyd -p project_name(scrapyd 是你的目标).你应该得到一个服务器响应代码 200 和一个 ok 状态.您也可以通过键入以下内容来检查部署是否成功:scrapy deploy -L scrapyd

    Deploy: type: scrapy deploy scrapyd -p project_name (scrapyd is your target). You should get a server response code 200 and an ok status. You can check if deploy was successful also by typing: scrapy deploy -L scrapyd

    调度:您需要为 Windows 安装 curl.方法如下:questions/9507353/steps-to-setup-curl-in-windows类型:curl http://localhost:6800/schedule.json -d project=project_name -d spider=spider_name同样,您应该获得 ok 状态,并且在您的浏览器中的 http://localhost:6800 作业下,您可以检查作业是否确实已安排.

    Scheduling: you need to install curl for windows. Here's how: questions/9507353/steps-to-setup-curl-in-windows type: curl http://localhost:6800/schedule.json -d project=project_name -d spider=spider_name Again, you should get an ok status, and in your browser at http://localhost:6800 under jobs you can check whether the job was indeed scheduled.

    我希望这会有所帮助.

    这篇关于无法识别 windows scrapyd-deploy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆