I am trying to get start_time from the scrapy stats.
At scrapy doc they say something like that.
https://docs.scrapy.org/en/latest/topics/stats.html
Okay, so, as they do, I catch the stats at init but I get an error like I am not passing the stats argument. I don't want it to be like an argument. Here is my code.
pipelines.py
class MongoDBPipeline(object):
def __init__(self, stats):
self.timeStarted = stats.get_value('start_time')
def process_item(self, item, spider):
valid = True
for data in item:
if not data:
valid = False
raise DropItem("Missing {0}!".format(data))
if valid:
item['createdAt'] = self.timeStarted
self.collection.insert(dict(item))
logging.info("Video cargado.")
return item
The error I get is this exactly:
TypeError: __init__() missing 1 required positional argument: 'stats'
Idk what to do. Thanks!