scrapy setting is not existed

2019-09-17 11:23发布

I have this line of code in my spider

settings.overrides['JOBDIR']= self.domain+"_"+self.Category+"_"+self.Action

I got this error:

__
    settings.overrides['JOBDIR']= self.domain+"_"+self.Category+"_"+self.Action
NameError: global name 'settings' is not defined

I run my spider from a script like this:

def setup_crawler(domain):
    spider = GeneralSpider(xmlFile=domain)
    settings = get_project_settings()
    crawler = Crawler(settings)
    crawler.configure()
    crawler.crawl(spider)
    crawler.start()

1条回答
姐就是有狂的资本
2楼-- · 2019-09-17 11:55

get_project_settings() looks for the environment variable SCRAPY_SETTINGS_MODULE to be set. Make sure it is set in your environment. The documentation here explains how to set it.

查看更多
登录 后发表回答