scapyd scrapyd-client scrapy使用ht

2020-03-02  本文已影响0人  cdz620

基本概念

scrapyd

scrapyd-client

安装过程

非Ubuntu,以下是mac平台的安装过程

scrapyd 配置

sudo mkdir /mnt/scrapyd   # 目录自己定
cd /mnt/scrapyd/
mkdir eggs
mkdir logs
mkdir items
mkdir dbs
sudo mkdir /etc/scrapyd/
cd /etc/scrapyd/

vi scrapyd.conf  配置如下:

[scrapyd]
eggs_dir    = /mnt/scrapyd/eggs
logs_dir    = /mnt/scrapyd/logs
logs_filename = {spider}-{Y}{m}{d}.log
items_dir   =
jobs_to_keep = 5
dbs_dir     = /mnt/scrapyd/dbs
max_proc    = 0
max_proc_per_cpu = 4
finished_to_keep = 100
poll_interval = 5
bind_address = 0.0.0.0
http_port   = 6100
debug       = off
runner      = scrapyd.runner
application = scrapyd.app.application
launcher    = scrapyd.launcher.Launcher
webroot     = scrapyd.website.Root
[services]
schedule.json     = scrapyd.webservice.Schedule
cancel.json       = scrapyd.webservice.Cancel
addversion.json   = scrapyd.webservice.AddVersion
listprojects.json = scrapyd.webservice.ListProjects
listversions.json = scrapyd.webservice.ListVersions
listspiders.json  = scrapyd.webservice.ListSpiders
delproject.json   = scrapyd.webservice.DeleteProject
delversion.json   = scrapyd.webservice.DeleteVersion
listjobs.json     = scrapyd.webservice.ListJobs

启动服务:/usr/bin/nohup /usr/local/bin/scrapyd > /dev/null 2>&1 &

scrapy项目scrapy.cfg 配置


[settings]
default = get_app_analytics.settings

[deploy:ios_analytics]
url = http://localhost:6800/
project = ios_get_app_analytics

scrapyd-client 使用scrapy-deploy部署

  1. cd 切换到scrapy.cfg所在目录

  2. 执行 scrapyd-deploy -v r1.0.0 ios_analytics -p ios_get_app_analytics

注意事项

ERROR: Error caught on signal handler: <bound method ?

unexpected keyword argument ‘_job’

使用例子

普通调度

curl http://localhost:6800/schedule.json -d project=ios_get_app_analytics -d spider=get_app_detail

传参数调度

curl http://localhost:6800/schedule.json -d project=ios_get_app_analytics -d spider=get_app_detail -d setting=APP_USER=xxx@icloud.com -d setting=APP_PASSWORD=haha

上一篇下一篇

猜你喜欢

热点阅读