I applied @fmango's code and improve it.
Instead of write a seperated runner file, just paste these code lines at the end of spider.
run python debugger. that's all
if __name__ == '__main__': import os from scrapy.cmdline import execute os.chdir(os.path.dirname(os.path.realpath(__file__))) SPIDER_NAME = MySpider.name try: execute( ['scrapy','crawl', SPIDER_NAME,'-s','FEED_EXPORT_ENCODING=utf-8', ] ) except SystemExit: pass