Import 无法使用CrawlerProcess导入模块
我使用的是一个爬行蜘蛛和scrapy命令行。一切都很好: scrapy crawl--nolog newproductcrawler 现在我想使用CrawlerProcess,当我导入它时,item模块崩溃了 发生异常:ModuleNotFoundError 没有名为“productsupervision”的模块 同样,在setting.py中,我使用类似的模块启用了管道,但它没有被加载Import 无法使用CrawlerProcess导入模块,import,module,scrapy,Import,Module,Scrapy,我使用的是一个爬行蜘蛛和scrapy命令行。一切都很好: scrapy crawl--nolog newproductcrawler 现在我想使用CrawlerProcess,当我导入它时,item模块崩溃了 发生异常:ModuleNotFoundError 没有名为“productsupervision”的模块 同样,在setting.py中,我使用类似的模块启用了管道,但它没有被加载 from productsupervision.responseitem import ResponseIt
from productsupervision.responseitem import ResponseItem
startUp.py
[...]
process = CrawlerProcess(get_project_settings())
process.crawl(NewproductcrawlerSpider ,url = 'http://www.example.com',domain='www.example.com' )
process.start()
NewproductcrawlerSpider.py
import scrapy
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule
from array import array
from productsupervision.responseitem import ResponseItem #EXCEPTION
class NewproductcrawlerSpider(CrawlSpider):
name = 'newproductcrawler'
文件夹结构为(无法再粘贴img!;o()
+产品监督
++蜘蛛
+++newproductcrawler.py(爬虫程序)
+++startUp.py
[...]
process = CrawlerProcess(get_project_settings())
process.crawl(NewproductcrawlerSpider ,url = 'http://www.example.com',domain='www.example.com' )
process.start()
++Middleware.py
++管道.py
++响应项
++设置.py
+刮痧
我正在寻找如何使用CrawlerProcess正确导入iteml模块的方法,发现:
startUp.py必须位于项目根级别。与scrapy.cfg文件夹相同