scrapy爬虫部署

2019-01-08  本文已影响0人  牛耀

第一步:安装使用到的相关库,终端进入有XXX.cfg文件的这个目录下

scrapyd

pip3 install scrapyd

scrapyd-client

pip3 install scrapyd-client

scrapyd-deploy -h

出现以下信息表示下载成功
Usage: scrapyd-deploy [options] [ [target] | -l | -L <target> ]

Deploy Scrapy project to Scrapyd server

Options:
  -h, --help            show this help message and exit
  -p PROJECT, --project=PROJECT
                        the project name in the target
  -v VERSION, --version=VERSION
                        the version to deploy. Defaults to current timestamp
  -l, --list-targets    list available targets
  -a, --deploy-all-targets
                        deploy all targets
  -d, --debug           debug mode (do not remove build dir)
  -L TARGET, --list-projects=TARGET
                        list available projects on TARGET
  --egg=FILE            use the given egg, instead of building it
  --build-egg=FILE      only build the egg, don't deploy it

注意:如果你使用windows的系统,需要进行以下配置

  1. 注意你的python运行环境,如果你是虚拟环境下运行的,你需要找到你的虚拟环境目录下的Scripts文件夹。新建一个:scrapyd-deploy.bat文件,如下图:


    image.png
  2. 打开这个文件写入:
@echo off
"D:\python3.5\python3.exe(你当前环境的python解释器路径)" "D:\python3.5\Scripts\scrapyd-deploy(存放scrapyd-deploy文件的路径)" %1 %2 %3 %4 %5 %6 %7 %8 %9

scrapyd-deploy -h
出现以上那一堆信息说明安装成功

第二步:修改scrapy项目目录下的scrapy.cfg配置文件

[deploy]
url=http://localhost:6800 # 本地
# 部署云服务器
url = 云服务器公网IP
project=项目名称

第三步:运行环境

scrapyd

常用命令

scrapyd-deploy -p 项目名称 --version 1.0(version版本号,可以省略)

curl http://localhost:6800/schedule.json -d project=项目名称 -d spider=xcfCrawlSpider

curl http://localhost:6800/cancel.json -d project=项目名称 -d job="jobid"

curl http://localhost:6800/listprojects.json

curl http://localhost:6800/listversions.json?project=项目名称

curl http://localhost:6800/listspiders.json?project=项目名称

curl http://localhost:6800/listjobs.json?project=项目名称

curl http://localhost:6800/delversion.json -d project=项目名称 -d version=r99

curl http://localhost:6800/delproject.json -d project=项目名称

上一篇 下一篇

猜你喜欢

热点阅读