Skip to content
Browse files

Updated input/ouput processor example according to #560.

  • Loading branch information
rmax authored and dangra committed Aug 8, 2014
1 parent db59ed9 commit f7c4ea81aa87045ac16cdbbf3d5d11a0cd51de12
Showing with 17 additions and 6 deletions.
  1. +17 −6 docs/topics/loaders.rst
@@ -182,21 +182,32 @@ output processors to use: in the :ref:`Item Field <topics-items-fields>`
metadata. Here is an example::

import scrapy
from scrapy.contrib.loader.processor import MapCompose, Join, TakeFirst
from w3lib.html import remove_entities
from myproject.utils import filter_prices
from scrapy.contrib.loader.processor import Join, MapCompose, TakeFirst
from w3lib.html import remove_tags

def filter_price(value):
if value.isdigit():
return value

class Product(scrapy.Item):
name = scrapy.Field(
price = scrapy.Field(
input_processor=MapCompose(remove_entities, filter_prices),
input_processor=MapCompose(remove_tags, filter_price),


>>> from scrapy.contrib.loader import ItemLoader
>>> il = ItemLoader(item=Product())
>>> il.add_value('name', [u'Welcome to my', u'<strong>website</strong>'])
>>> il.add_value('price', [u'&euro;', u'<span>1000</span>'])
>>> il.load_item()
{'name': u'Welcome to my website', 'price': u'1000'}

The precedence order, for both input and output processors, is as follows:

1. Item Loader field-specific attributes: ``field_in`` and ``field_out`` (most

0 comments on commit f7c4ea8

Please sign in to comment.