Scrapy crawler in Cron job

后端 未结 7 1634
遥遥无期
遥遥无期 2020-12-13 15:11

I want to execute my scrapy crawler from cron job .

i create bash file getdata.sh where scrapy project is located with it\'s spiders

#!/bin/bash
cd /         


        
7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-13 15:50

    For anyone who used pip3 (or similar) to install scrapy, here is a simple inline solution:

    */10 * * * * cd ~/project/path && ~/.local/bin/scrapy crawl something >> ~/crawl.log 2>&1
    

    Replace:

    */10 * * * * with your cron pattern

    ~/project/path with the path to your scrapy project (where your scrapy.cfg is)

    something with the spider name (use scrapy list in your project to find out)

    ~/crawl.log with your log file position (in case you want to have logging)

提交回复
热议问题