正如错误所说,Quote5未定义,您需要在将其传递给方法之前定义Quote5。或者尝试这样的方法:
run_spider(âquotes5â)
编辑:
import WS_Vardata.spiders.quotes_spiders as quote_spider_module
def run_spider(spiderName):
#get the class from within the module
spiderClass = getattr(quote_spider_module, spiderName)
#create the object and your good to go
spiderObj= spiderClass()
crawler = CrawlerRunner(get_project_settings()) #from Scrapy docs
crawler.crawl(spiderObj)
run_spider("QuotesSpider")
此脚本应与ws_vardata在同一目录中运行
所以在你的例子中:
- TEST
| the_code.py
| WS_Vardata
| spiders
| quotes_spider <= containing QuotesSpider class