mirror of https://github.com/scrapy/scrapy.git
added items section (ScrapedItems) to proposed doc
--HG-- extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40835
This commit is contained in:
parent
3a3723ba2e
commit
d98f35af94
|
|
@ -11,6 +11,7 @@ Proposed documentation
|
|||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
items
|
||||
spiders
|
||||
|
||||
.. toctree::
|
||||
|
|
|
|||
|
|
@ -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'})
|
||||
|
||||
Loading…
Reference in New Issue