from tutorial.items import DmozItem报错?求解答

新手上路,请多包涵
**items.py文件**
import scrapy
from scrapy.item import Item, Field  

class TutorialItem(scrapy.Item):
    # define the fields for your item here like:
    # name = scrapy.Field()
    pass

class DmozItem(Item):  
    title = Field()  
    link = Field()  
    desc = Field()  
    
**dmoz_spider.py文件**
from scrapy.spiders import Spider
from scrapy.selector import Selector
from tutorial.items import DmozItem
import sys
sys.path.append("..")

class DmozSpider(Spider):  
    name = "dmoz"  
    allowed_domains = ["dmoz.org"]  
    start_urls = [  
        "http://www.dmoz.org/Computers/Programming/Languages/Python/Books/",  
        "http://www.dmoz.org/Computers/Programming/Languages/Python/Resources/"  
    ]  
  
    def parse(self, response):  
        sel = Selector(response)  
        sites = sel.xpath('//ul[@class="directory-url"]/li')  
        items = []  
        for site in sites:  
            item = DmozItem()  
            item['title'] = site.xpath('a/text()').extract()  
            item['link'] = site.xpath('a/@href').extract()  
            item['desc'] = site.xpath('text()').extract()  
            items.append(item)  
        return items  
        
 **错误代码**
Traceback (most recent call last):
  File "F:\tutorial\tutorial\spiders\dmoz_spider.py", line 3, in <module>
    from tutorial.items import DmozItem
ImportError: No module named tutorial.items
[Finished in 0.6s with exit code 1
阅读 4.7k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题