- linux端安装scrapyd和scrapyd-client。windows端安装scrapyd-client
- 修改linux端scrapyd库里面的配置文件default_scrapyd.conf
- pip3 show scrapyd查看位置
- 11行 bind_address = 0.0.0.0 允许其他的IP地址访问
- 修改项目配置文件cfg(项目要传到linux上的)(没什么事的话别在这文件里写中文)
[settings]
default = biquge.settings
[deploy:scrapyd_biquge] # 给部署起一个名字
# 开启的端口
url = http://localhost:6800/
# 项目名称
project = biquge
- 开启部署
- linux端新建一个文件夹,并在该目录下执行scrapyd(或者守护进程nohup scrapyd & > a)
- 这时可以通过http://192.168.249.128:6800查看(ip)如果无法访问需要检查一下linux的防火墙
- 发布爬虫任务(把整个项目上线)
- linux端切换到爬虫项目文件夹下
- scrapyd-deploy 部署名字 -p 项目名称
- scrapyd-deploy scrapyd_biquge -p biquge
- 会提示ok
- 第一次运行会遇到一个小问题,百度即可解决
- 从windows端开启爬虫任务
- curl http://linuxip:6800/schedule.json -d project=项目名 -d spider=任务名(格式)
- curl http://192.168.249.128:6800/schedule.json -d project=biquge -d spider=crawlbiquge
- 关闭爬虫任务
- curl http://192.168.249.128:6800/cancel.json -d project=biquge -d job=6dffea160ad511ecbc5c00163e0e710d