在scrapy教程之后,我收到导入错误。
我的结构是
stalk
|-bin
|-include
|-lib
|-properties
|-properties
| |-spiders\
| |-__init__.py
| |-items.py
| |-pipelines.py
| |-settings.py
|
|scrapy.cfg
my items.py
# -*- coding: utf-8 -*-
# Define here the models for your scraped items
#
# See documentation in:
# http://doc.scrapy.org/en/latest/topics/items.html
from scrapy.item import Item, Field
class PropertiesItem(Item):
# Primary fields
title = Field()
price = Field()
description = Field()
address = Field()
image_urls = Field()
# Calculated fields
images = Field()
location = Field()
# Housekeeping fields
url = Field()
project = Field()
spider = Field()
server = Field()
date = Field()
pass
我的basic.py
# -*- coding: utf-8 -*-
import scrapy
from properties.items import PropertiesItem
class BasicSpider(scrapy.Spider):
name = "basic"
allowed_domains = ["web"]
start_urls = (
'http://www.example.com/',
)
def parse(self, response):
result = response.xpath('//*[@id="cap"]/a/h5/text()').extract()
# self.log("title :{}".format(result))
item = PropertiesItem()
item['title'] = result
pass
当我尝试导入此
时from properties.items import PropertiesItem
单词items是highlited,PropertiesItem下面有红色的波浪形错误行。我做错了什么?
使用django 1.10和python 3.5编辑Im