scrapy: Call a function when a spider quits

后端 未结 6 1157
猫巷女王i
猫巷女王i 2020-11-27 14:29

Is there a way to trigger a method in a Spider class just before it terminates?

I can terminate the spider myself, like this:

class MySpider(CrawlS         


        
6条回答
  •  眼角桃花
    2020-11-27 15:15

    Just to update, you can just call closed function like this:

    class MySpider(CrawlSpider):
        def closed(self, reason):
            do-something()
    

提交回复
热议问题