为crontab文件和调度作业爬网文件系统。

cronster的Python项目详细描述


克朗斯特

https://img.shields.io/pypi/l/cronster.svghttps://img.shields.io/pypi/pyversions/cronster.svghttps://img.shields.io/pypi/v/cronster.svghttps://img.shields.io/pypi/wheel/cronster.svghttps://readthedocs.org/projects/cronster/badge/?version=latesthttps://travis-ci.org/florianeinfalt/cronster.svg?branch=master

Full Documentation

安装

要安装cronster,请键入:

$ pip install cronster

开始

安装redis

要开始使用cronster,请在计算机上安装Redis。 (本例中的MacOS&Homebrew):

$ brew install redis
$ brew services start redis

Digital Ocean有一个关于 如何在ubuntu上安装redis。

运行爬虫程序

假设Redis以默认配置在您的计算机上运行 如果要从~/projects爬网,请运行以下命令:

$ cronster_crawler -r ~/projects

完整的帮助输出解释了cli应用程序的其他选项。 可以在不同的 主机/端口或是否要调整爬网间隔:

Usage: cronster_crawler [OPTIONS]

Options:
  -r, --root TEXT           Crawling root, default: the current working directory
  -h, --cache-host TEXT     Cache host, default: localhost
  -p, --cache-port INTEGER  Cache port, default: 6379(Redis default)
  -i, --interval INTEGER    Crawling interval, default: 2 seconds
  --help                    Show this message and exit.

运行调度程序

假设Redis以默认配置在您的计算机上运行, 运行以下命令:

$ cronster_scheduler

完整的帮助输出解释了cli应用程序的其他选项。 可以更改Redis-相关参数应该Redis在 不同的主机或端口:

Usage: cronster_scheduler [OPTIONS]

Options:
  -h, --cache-host TEXT     Cache host, default: localhost
  -p, --cache-port INTEGER  Cache port, default: 6379(Redis default)
  --help                    Show this message and exit.

写一个crontab文件

将以下YAML文件写入~/projects/crontab(或任何其他位置 层次结构中位于root位置下的任何位置:

test_job:cmd:echo "Hello, World!"schedule:"*/5****"

你应该在下一次爬网时看到爬虫抓到了作业 应该看到调度程序每五分钟运行一次作业。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java将字符串拆分为带关键字的部分   删除数据库后未指定java数据源问题“url”属性   网络化java多人游戏连接   Java当新字符串等于旧字符串时,为什么substring()不创建新对象?   一个实例到多个bean的java注入   JavaSpringMVC验证错误消息   java总结if语句,并从另一个对象(如字符串[])读取if条件(动态if)   需要多个输入的Java IF语句   jsf如何选择正确的bean范围?   java将数据库值加载到组合框JSP,Hibernate   一次活动中的java 3布局   团队和球员反对Java的困难   java ActionListener如何知道按下了哪个按钮?