我的蜘蛛
中有这行代码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()
答案 0 :(得分:0)
get_project_settings()
查找要设置的环境变量SCRAPY_SETTINGS_MODULE
。确保它已在您的环境中设置。文档here解释了如何设置它。