Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run scrapy runspider without the printed logs

I'm executing a scrapy spider using:

scrapy runspider my_spider.py -o results.json

How do I execute it silently, i.e., without all the spider print logs?

like image 861
Miguel Avatar asked Jan 07 '23 04:01

Miguel


2 Answers

You can use the command line option --nolog which sets LOG_ENABLED to False

like image 192
Pythonista Avatar answered Jan 18 '23 12:01

Pythonista


Another answer would be to add the log settings into your settings.py. Which is a bit different than the exact original question.

Info here: http://doc.scrapy.org/en/latest/topics/logging.html

My code for logs will make it export to a logfile in the folder. It will run silent in terminal but show anything thats NOT DEBUG in the logfile. So you can track it if you want.

LOG_ENABLED = True
LOG_LEVEL = 'INFO' # Levels: CRITICAL, ERROR, WARNING, INFO, DEBUG
LOG_FILE = 'logfile.log'

This will also make it so that you dont have to attach the --no-log when executing

like image 41
Max Uland Avatar answered Jan 18 '23 12:01

Max Uland