ScrapyPreactionWaring:命令';的默认“爬虫程序”已弃用,将被删除。使用“create_crawler”方法实例化爬虫
刮擦版0.19 我正在使用此页()上的代码。当我运行ScrapyPreactionWaring:命令';的默认“爬虫程序”已弃用,将被删除。使用“create_crawler”方法实例化爬虫,scrapy,Scrapy,刮擦版0.19 我正在使用此页()上的代码。当我运行scrapy allcrawl时,我得到了 ScrapyDeprecationWaring: Command's default `crawler` is deprecated and will be removed. Use `create_crawler` method to instantiate crawlers 代码如下: from scrapy.command import ScrapyCommand import urllib
scrapy allcrawl
时,我得到了
ScrapyDeprecationWaring: Command's default `crawler` is deprecated and will be removed. Use `create_crawler` method to instantiate crawlers
代码如下:
from scrapy.command import ScrapyCommand
import urllib
import urllib2
from scrapy import log
class AllCrawlCommand(ScrapyCommand):
requires_project = True
default_settings = {'LOG_ENABLED': False}
def short_desc(self):
return "Schedule a run for all available spiders"
def run(self, args, opts):
url = 'http://localhost:6800/schedule.json'
for s in self.crawler.spiders.list(): #this line raise the warning
values = {'project' : 'YOUR_PROJECT_NAME', 'spider' : s}
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
log.msg(response)
如何修复弃用警告
谢谢使用:
crawler = self.crawler_process.create_crawler()
它抛出AttributeError:“CrawlerProcess”对象在scrapy 1.0.3中没有属性“create\u crawler”。如何修复此问题?@Ashish蜘蛛加载器它在
self.crawler\u process.spider\u loader
上公开,因此您可以直接在该对象上调用.list()
。