从源码开始学习Scrapy系列05-edit指令

代码调试

进入edit模块的run方

获取EDITOR配置

editor = self.settings['EDITOR']

配置内容其实就是一个编辑指令

EDITOR = 'vi'
if sys.platform == 'win32':
    EDITOR = '%s -m idlelib.idle'

爬虫加载器根据爬虫项目名加载当前爬虫

spidercls = self.crawler_process.spider_loader.load(args[0])

获取当前爬虫模块的文件内容

sfile

将编译文件替换为执行文件

sfile = sfile.replace('.pyc', '.py')

执行编辑指令,结束程序

self.exitcode = os.system('%s "%s"' % (editor, sfile))


以上就是editor指令的大致执行逻辑,不是重点,就略过把

猜你喜欢

转载自blog.csdn.net/wang1472jian1110/article/details/80355131
今日推荐