我想在蜘蛛关闭时向我发送电子邮件
我看这source,我可以收到邮件。但我发现它会写failure.getTraceback()
当蜘蛛获取源代码的错误如何将ScrapyFileLogObserver文件发送到我的电子邮件
部分:
def spider_error(self, failure, response, spider):
self.files[spider.name + '.log'].write(failure.getTraceback())
self.num_errors += 1
但我想让它可以在控制台日志发送到我的邮箱是这样的:
2014-08-28 00:30:33+0000 [scrapy] INFO: Scrapy 0.24.2 started (bot: shopping)
2014-08-28 00:30:33+0000 [scrapy] INFO: Optional features available: ssl, http11, boto, django
2014-08-28 00:30:34+0000 [scrapy] WARNING: can't find the images!: http://www.example.com
2014-08-28 00:30:34+0000 [email] ERROR: Spider error processing <GET http://www.example.com
我需要这个数,因为如果我得到的WARNING: can't find the images!: http://www.example.com
,我可以运行其它蜘蛛拿到错过图像
现在我的方法是使用ScrapyFileLogObserver(open("spider.log", 'w'), level=log.INFO).start()
写在一个文件。运行蜘蛛后,我打开它来检查是否somtthing wrong.I不知我是否可以发送此文件到我的电子邮件或只是文件中的文本
有人可以教我如何做这个?谢谢。