0
我想让这个与Scrapy一起工作,它确实令人沮丧。我无法导入items.py文件。我已经尝试了一切,包括加入from__future__ import absolute import
,并且用几次不同的名称销毁和重新创建项目和蜘蛛。在scrapy蜘蛛上导入项目时出错
from __future__ import absolute_import
import scrapy
from kano.items import KanoItem
class KatscrapSpider(scrapy.Spider):
name = "katscrap"
allowed_domains = ["kat.cr"]
start_urls = (
'https://kat.cr/usearch/category%3Amusic/2/?field=seeders&sorder=desc',
)
def parse(self, response):
self.log("link: %s" % response.xpath(
'//*[@id][starts-with(@id,"torrent")]/td[1]/div[1]/a[4]//@href').extract())
item['torrent_url'] = response.xpath(
'//*[@id][starts-with(@id,"torrent")]/td[1]/div[1]/a[4]//@href').extract()
但我仍然得到:
ImportError: No module named kano.items
这似乎是一种具有scrapy常见的错误的,有人可以解释为什么出现这种情况?
编辑:
这是我的树结构:
├── kano
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── items.py
│ ├── pipelines.py
│ ├── settings.py
│ ├── settings.pyc
│ └── spiders
│ ├── __init__.py
│ ├── __init__.pyc
│ └── kat.py
└── scrapy.cfg
什么是您的项目的目录结构? – Rahul
我已经添加了树到我的问题 – xavier
你如何运行蜘蛛?它是'Scrapy抓取katscrap'还是'python kat.py'? – Rahul