如何自动运行抓取工具? [英] How to run crawler automatically?

查看:145
本文介绍了如何自动运行抓取工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用django和scrapy框架来完成一个项目。在我的项目中,有两个爬虫。现在,我希望这些抓取工具每天自动运行一次或两次。那么我该如何实现呢?如何实现?使用cron工作的简单想法是我在寻找什么?所以我正在寻找一些好的和容易的参考从开始。

I am using django and scrapy framework to complete a project. In my project, there are two crawlers. Now I want those crawlers to run once or twice a day automatically. So how can i achieve that? How is that achieved? Simple idea on using cron job is what I am looking for? So I am looking for some good and easy reference to start with.

推荐答案

我认为cronjob将是最简单的方法。

I think a cronjob would be the easiest way to go.

只需将以下内容添加到您的' / etc / crontab '(或使用 crontab -e ):

Simply add the following to your '/etc/crontab' (or use crontab -e):

0 0 * * * python /path/to/your/script.py

这将在每天的00:00运行

This will run every day at 00:00

这里还有一些不错的参考网站: http:// www。 thesitewizard.com/general/set-cron-job.shtml

Also here is some nice reference website: http://www.thesitewizard.com/general/set-cron-job.shtml

编辑:如果您不希望将输出发送到您的邮件,请使用:

edit: if you do not want the output be sent to your mail just use:

0 0 * * * python /path/to/your/script.py > /dev/null

0 0 * * * python /path/to/your/script.py >/dev/null 2>&1

第一个将销毁正常的输出(但会记录任何错误),第二个将销毁任何输出。

The first will "destroy" the 'normal' output (but will log any errors), the second will "destroy" any output.

这篇关于如何自动运行抓取工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆