Reading settings in spider scrapy

Viewed 8514

I wrote a small scrapy spider. Following is my code

class ElectronicsSpider(scrapy.Spider):
    name = "electronics"
    allowed_domains = ["www.olx.com"]
    start_urls = ['http://www.olx.com/']

    def parse(self, response):
        pass

My question is, I want to read the name,allowed_domains and start_urls using setting. How can i do this?

I tried importing

 from scrapy.settings import Settings

also tried this

 def __init__(self,crawler):
        self.settings = crawler.settings

but I got none/error. Help me to read settings in my spider?

3 Answers

self.settings is not yet initiated in __init__(). You can check self.settings in start_requests().

def start_requests(self): 
    print self.settings
Related