我正在尝试覆盖在脚本中调用的爬虫的一些设置,但这些设置似乎没有生效:
from scrapy import log
from scrapy.crawler import CrawlerProcess
from scrapy.utils.project import get_project_settings
from someproject.spiders import SomeSpider
spider = SomeSpider()
overrides = {
'LOG_ENABLED': True,
'LOG_STDOUT': True,
}
settings = get_project_settings()
settings.overrides.update(overrides)
log.start()
crawler = CrawlerProcess(settings)
crawler.install()
crawler.configure()
crawler.crawl(spider)
crawler.start()
在蜘蛛中:
from scrapy.spider import BaseSpider
class SomeSpider(BaseSpider):
def __init__(self):
self.start_urls = [ 'http://somedomain.com' ]
def parse(self, response):
print 'some test' # won't print anything
exit(0) # will normally exit failing the crawler
通过定义LOG_ENABLED
and LOG_STDOUT
,我希望在日志中看到“一些测试”字符串。此外,我似乎无法将日志重定向到LOG_FILE
我尝试过的其他一些设置中。
我一定做错了什么......请帮忙。=D