(1)安装环境 ?
pip install scrapyd
pip install scrapy-client
(2)在cmd中启动命令scrapyd,并不要关。

(3)在浏览器中输入127.0.0.1:6800

(4)打开scrapy项目,有个scrapy.cfg文件,按如下进行配置

?
?(4)scrapyd-deploy -l 可以查看当前部署的爬虫项目,但是当我输入这段命令的 时候显示这个命令不是内部或外部命令。(-L的小写)

解决方法是在python 目录下的 Scripts文件中,我的路径是 “C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Scripts”,在下面创建两个文件,scrapy.bat 和 scrapyd-deploy.bat (新建 txt 文本文档,然后更改后缀名为 .bat)
编辑scrapyd-deloy.bat:
@echo off
#python.exe路径 scrapyd-deploy路径
C:\Users\Administrator\AppData\Local\Programs\Python\Python38\python.exe C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Scripts\scrapyd-deploy %*
?
编辑scrapy.bat:
@echo off
#python.exe路径 scrapyd路径
C:\Users\Administrator\AppData\Local\Programs\Python\Python37\python.exe C:\Users\Administrator\AppData\Local\Programs\Python\Python37\Scripts\scrapyd %*
现在重新打开命令框,再运行scrapyd-deploy -l 就可以了,可以看到我这里的部署名称和端口信息

?(5)发布爬虫,部署到scrapyd,

?(6)启动爬虫,这里要用到curl命令行工具,下载地址如下。
(curl安装目录,1.curl命令下载安装并使用(Windows版本)_IT生涯——知其然知其所以然-CSDN博客_curl下载安装2.【curl】Windows上curl的安装_michaelwoshi的博客-CSDN博客_curl windows
3. curl扩展学习:每天学习一个命令:curl 命令行下载工具 | Verne in GitHub)
curl http://127.0.0.1:6800/schedule.json -d project=工程名 -d spider=爬虫名
工程名就是你之前的项目名称,爬虫名就对应你scrapy工程里爬虫文件的name(也可以叫爬虫名)

|