'how to run spiders in script with it's name ( Scrapy 0.24.1 and Python 2.7.10 )

I'm using Scrapy 0.24.1 and Python 2.7.10 in my project. I have some spiders with custom settings. my crawler works fine with the command line and the command is like this:

scrapy crawl sample_spider --set TYPE="live" --set FROM="Berlin" --set TO="London" --set DATE="2022-06-06"

in the spider, I have a stats property, and I need to access it after completing the process. I want to run the spider with its name in the script s then I can access the properties easily. I read the docs of Scrapy 0.24.1, but I could not find any piece of code that works.
I tested CrawlerProcess and Crawler but it is not working. I'm not sure where is the problem.

Here is the documentation of this version: https://docs.scrapy.org/en/0.24/intro/tutorial.html



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source