ModuleNotFoundError: No module named 'Scrapy'

ModuleNotFoundError: No module named 'Scrapy'

import Scrapy


class NgaSpider(Scrapy.Spider):
    name = "NgaSpider"
    host = "http://bbs.ngacn.cc/"
    start_urls = [
        "http://bbs.ngacn.cc/thread.php?fid=406",
    ]


    def parse(self, response):
        print ("response.body")

错误: ModuleNotFoundError:没有名为 'Scrapy'

的模块

如何解决这个问题?

您错误地导入了 scrapy 模块。

here.

中查找简单教程和参考资料

您必须进行以下更改:

import scrapy # Change here


class NgaSpider(scrapy.Spider): # Change here too
    name = "NgaSpider"
    host = "http://bbs.ngacn.cc/"
    start_urls = [
        "http://bbs.ngacn.cc/thread.php?fid=406",
    ]


    def parse(self, response):
        print ("response.body")

Assuming you are using 1.3 version of it.

检查使用

pip show scrapy