IndentationError: unexpected indent (Scrapy)

i'm trying to load my scrapy but, as you can see, there's a error:

File "rotina\spiders\rotina1.py", line 4, in <module>
from rotina.items import ImobiliariasItem
File "rotina\items.py", line 6
tipo = Field()
^
IndentationError: unexpected indent

My items.py is:

from scrapy.item import Item, Field

    categoria = Field()
    tipo = Field()
    qtd_quartos = Field()
    qtd_banheiros = Field()
    qtd_garagem = Field()
    descricao = Field()
    photo = Field()

What can i do?

Answers


A general item declaration is missing. The interpreter does not know to which item it should assign the fields:

from scrapy.item import Item, Field

class MyItem(Item):

    categoria = Field()
    tipo = Field()
    qtd_quartos = Field()
    qtd_banheiros = Field()
    qtd_garagem = Field()
    descricao = Field()
    photo = Field()

Check out this example in the documentation: http://doc.scrapy.org/en/latest/topics/items.html#declaring-items

In order to get the indentation straight - you can use tools like tabnanny: http://pymotw.com/2/tabnanny/


Need Your Help

Using $this in "anonymous" object

php anonymous-class

I am using the following class to mimic anonymous objects in PHP: