scrapy设置不存在

时间:2014-03-17 20:55:06

标签: python python-2.7 scrapy

我的蜘蛛

中有这行代码
settings.overrides['JOBDIR']= self.domain+"_"+self.Category+"_"+self.Action

我收到了这个错误:

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

我从这样的脚本中运行我的蜘蛛:

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

1 个答案:

答案 0 :(得分:0)

get_project_settings()查找要设置的环境变量SCRAPY_SETTINGS_MODULE。确保它已在您的环境中设置。文档here解释了如何设置它。