I know you can access spider variables in process_item(), but how can I access spider variables in pipeline init function?
class SiteSpider(CrawlSpider):
def __init__(self):
self.id = 10
class MyPipeline(object):
def __init__(self):
...
I also need to access CUSTOM_SETTINGS_VARIABLE in MyPipeline.
You can't access the spider instance as the pipeline initialization is done when the engine starts. In fact, you have to think that your pipeline handles multiple spiders and not just one spider.
Having said that, you can hook the
spider_opened
signal to access the spider instance when it starts.