<p dir="auto">I didn't find a good way to use different 'process_item'  methods to different classes of Items.</p>
<p dir="auto">For example we could create two item classes to crawl and then store in db:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class Headers(item):
    url = Field()
    response_code = Field()
    content_type = Field()

class Body(item):
    title = Field()
    h1 = Field()"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-v">Headers</span>(<span class="pl-s1">item</span>):
    <span class="pl-s1">url</span> <span class="pl-c1">=</span> <span class="pl-v">Field</span>()
    <span class="pl-s1">response_code</span> <span class="pl-c1">=</span> <span class="pl-v">Field</span>()
    <span class="pl-s1">content_type</span> <span class="pl-c1">=</span> <span class="pl-v">Field</span>()

<span class="pl-k">class</span> <span class="pl-v">Body</span>(<span class="pl-s1">item</span>):
    <span class="pl-s1">title</span> <span class="pl-c1">=</span> <span class="pl-v">Field</span>()
    <span class="pl-s1">h1</span> <span class="pl-c1">=</span> <span class="pl-v">Field</span>()</pre></div>
<p dir="auto">Than in item pipeline we would need to do something like this:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class StoreInDB(object):

    def process_item(self. item, spider):
        if isinstance(item, Headers):
            return self.storeHeaders(item, spider)
        elif isinstance(item, Body):
            return self.storeBody(item, spider)

    def storeHeaders():
        pass # make some things with Headers item here

    def storeBody():
        pass # make some things with Body item here"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-v">StoreInDB</span>(<span class="pl-s1">object</span>):

    <span class="pl-k">def</span> <span class="pl-en">process_item</span>(<span class="pl-s1">self</span>. <span class="pl-s1">item</span>, <span class="pl-s1">spider</span>):
        <span class="pl-k">if</span> <span class="pl-en">isinstance</span>(<span class="pl-s1">item</span>, <span class="pl-v">Headers</span>):
            <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-en">storeHeaders</span>(<span class="pl-s1">item</span>, <span class="pl-s1">spider</span>)
        <span class="pl-k">elif</span> <span class="pl-en">isinstance</span>(<span class="pl-s1">item</span>, <span class="pl-v">Body</span>):
            <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-en">storeBody</span>(<span class="pl-s1">item</span>, <span class="pl-s1">spider</span>)

    <span class="pl-k">def</span> <span class="pl-en">storeHeaders</span>():
        <span class="pl-k">pass</span> <span class="pl-c"># make some things with Headers item here</span>

    <span class="pl-k">def</span> <span class="pl-en">storeBody</span>():
        <span class="pl-k">pass</span> <span class="pl-c"># make some things with Body item here</span></pre></div>
<p dir="auto">Wouldn't it be nice to put this functionality in base class, so we would have some dict or function to map item to the correct processor? Sure, current behavior would stay as default. Here is what i'm talking about:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from project.items import Headers, Body
from scrapy.contrib.pipeline import Pipeline

class StoreInDB(Pipeline):


    self.assignItemProcessor(itemclass=Headers, processor=self.storeHeaders)
    self.assignItemProcessor(itemclass=Body, processor=self.storeBody)

    def storeHeaders():
        pass # make some things with Headers item here

    def storeBody():
        pass # make some things with Body item here"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">project</span>.<span class="pl-s1">items</span> <span class="pl-k">import</span> <span class="pl-v">Headers</span>, <span class="pl-v">Body</span>
<span class="pl-k">from</span> <span class="pl-s1">scrapy</span>.<span class="pl-s1">contrib</span>.<span class="pl-s1">pipeline</span> <span class="pl-k">import</span> <span class="pl-v">Pipeline</span>

<span class="pl-k">class</span> <span class="pl-v">StoreInDB</span>(<span class="pl-v">Pipeline</span>):


    <span class="pl-s1">self</span>.<span class="pl-en">assignItemProcessor</span>(<span class="pl-s1">itemclass</span><span class="pl-c1">=</span><span class="pl-v">Headers</span>, <span class="pl-s1">processor</span><span class="pl-c1">=</span><span class="pl-s1">self</span>.<span class="pl-s1">storeHeaders</span>)
    <span class="pl-s1">self</span>.<span class="pl-en">assignItemProcessor</span>(<span class="pl-s1">itemclass</span><span class="pl-c1">=</span><span class="pl-v">Body</span>, <span class="pl-s1">processor</span><span class="pl-c1">=</span><span class="pl-s1">self</span>.<span class="pl-s1">storeBody</span>)

    <span class="pl-k">def</span> <span class="pl-en">storeHeaders</span>():
        <span class="pl-k">pass</span> <span class="pl-c"># make some things with Headers item here</span>

    <span class="pl-k">def</span> <span class="pl-en">storeBody</span>():
        <span class="pl-k">pass</span> <span class="pl-c"># make some things with Body item here</span></pre></div>
<p dir="auto">I can write the code if you guys think it's useful. It certainly is for me.</p>
<p dir="auto">Access the <a href="http://files.qidian.com/Author4/3615059/88542882.txt" rel="nofollow">text page(not mine)</a> by browsers or wget and you will find  the response content is not duplicate, but scrapy's <code class="notranslate">response.body</code> is duplicate. I had tried set the scrapy's headers same as a real brower's, but it is still duplicate.</p>
<p dir="auto">Just use the follow sample code, and you will find the issue.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="scrapy shell &quot;http://files.qidian.com/Author4/3615059/88542882.txt&quot;"><pre class="notranslate"><code class="notranslate">scrapy shell "http://files.qidian.com/Author4/3615059/88542882.txt"
</code></pre></div>
<p dir="auto">Sorry for my bad english.</p>