added items section (ScrapedItems) to proposed doc

--HG--
extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40835
This commit is contained in:
Ismael Carnales 2009-02-09 14:29:48 +00:00
parent 3a3723ba2e
commit d98f35af94
2 changed files with 43 additions and 0 deletions

View File

@ -11,6 +11,7 @@ Proposed documentation
.. toctree::
:maxdepth: 1
items
spiders
.. toctree::

View File

@ -0,0 +1,42 @@
.. _items:
=====
Items
=====
In Scrapy, Items are the placeholder to use for the scraped data. They are
represented by a :class:`~scrapy.item.ScrapedItem` object, or any subclass
instance, and store the information in instance attributes.
.. module:: scrapy.item
ScrapedItem
-----------
.. autoclass:: ScrapedItem(object)
:members:
.. automethod:: __init__
:param data: A dictionary containing attributes and values to be set
after instancing the item.
Examples
--------
Creating an item and setting some attributes::
>>> from scrapy.item import ScrapedItem
>>> item = ScrapedItem()
>>> item.name = 'John'
>>> item.last_name = 'Smith'
>>> item.age = 23
>>> item
ScrapedItem({'age': 23, 'last_name': 'Smith', 'name': 'John'})
Creating an item and setting its attributes inline::
>>> person = ScrapedItem({'name': 'John', 'age': 23, 'last_name': 'Smith'})
>>> person
ScrapedItem({'age': 23, 'last_name': 'Smith', 'name': 'John'})