scrapyd和spiderkeeper实现scarpy项目的可视化操作

本文介绍了scrapyd和spiderKeeper这两个scrapy项目的可视化管理工具。scrapyd是一个用于运行scrapy爬虫的服务,支持HTTP JSON接口控制爬虫。spiderKeeper则提供了一个网页端的可视化界面,方便进行一键部署、定时任务等操作,减少了与命令行的交互。详细内容包括scrapyd的安装、项目部署,以及spiderKeeper的安装和使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

scrapy可视化管理工具

scrapyd

  • 什么是scrapyd?

    Scrapyd是一个服务,用来运行scrapy爬虫的

    它允许你部署你的scrapy项目以及通过HTTP JSON的方式控制你的爬虫

  • scrapyd官方文档

    https://scrapyd.readthedocs.io/en/stable/
    
  • 安装scrapyd服务

$ pip install scrapyd
  • 如何部署爬虫项目到scrapyd中
# 官方文档
Deploying your project involves eggifying it and uploading the egg to Scrapyd via the addversion.json endpoint. You can do this manually, but the easiest way is to use the scrapyd-deploy tool provided by scrapyd-client which will do it all for you.

# 即使用scrapyd-client 中提供的scrapyd-deploy tool来进行部署
  • scrapyd-client
Scrapyd-client is a client for Scrapyd. It provides the general scrapyd-client and the scrapyd-deploy utility which allows you to deploy your project to a Scrapyd server.
  • github网址
https://github.com/scrapy/scrapyd-client
  • 安装scrapyd-client
$ pip install scrapyd-client
  • scrapyd-deploy的使用

首先进入scrapy.cfg进行配置

# scrapy.cfg

# [deploy:example]可以给你的项目取别名
[deploy]
url = http://scrapyd.example.com:端口号
# 用户名和密码可以不设置,如果设置访问服务器所需的用户名和密码
# username = scrapy
# password = secret
project = yourproject
  • 首先开启scrapyd服务
$ scrapyd
"http://127.0.0.1:6800/"
# 可以通过该网址进行访问,即该url就是项目部署的URL
  • 网站访问效果如下图所示
    在这里插入图片描述

  • 进行部署

$ scrapyd-deploy example(这个是你部署取得别名) -p scrapyProject
  • 效果展示

在这里插入图片描述

  • list all available targets
$ scrapyd-deploy -l
  • list projects available on a specific target
$ scrapyd-deploy -L centos
  • 部署完毕可以看到可用的项目添加了进去

在这里插入图片描述

spiderKeeper

  • SpiderKeeper是什么?

    SpdierKeeper通过配合scrpyd管理爬虫,支持一键式部署,定时采集任务,启动,暂停等一系列的操作.原理
    是: 对scrapyd的api进行封装,最大限度减少你跟命令行交互次数.

    简单来说是网页端的可视化界面,不用通过命令行来开始执行爬虫

  • 安装SpiderKeeper

$ pip install SpiderKeeper 
  • 连接服务端地址
# 查看命令
spiderkeep --help 
参数
 --server=SERVERS      servers, default: ['http://localhost:6800']

spiderkeeper --server=http://localhost:6800
  • spiderkeeper的开放端口是5000
# 通过127.0.0.1:5000来查看
# 默认的用户名和密码都是admin
  • 操作界面

在这里插入图片描述

  • 选择创建项目

在这里插入图片描述

  • 使用提示命令来打包项目
$ scrapyd-deploy --build-egg output.egg
  • 创建周期性任务爬虫

在这里插入图片描述

  • 至此可以完成爬虫项目的可视化
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值