title: scrapy add data to the json file from different functions
body: <p>I'm new to both scrapy and json, and working on a scrapy project. this is my script:</p>
  <pre><code>import scrapy
  
  class MoulaviSpider(scrapy.Spider):
      name = &quot;moulavi&quot;
  
      def start_requests(self):
      start_urls = [
          'https://ganjoor.net/moulavi/masnavi/daftar1/sh1/',
          'https://ganjoor.net/moulavi/masnavi/daftar1/sh2/',
      ]
          for url in start_urls:
              yield scrapy.Request(url=url, callback=self.title)
  
      def title(self, response):
          #'hetitle': response.css('h2').extract(), 
          return scrapy.Request(callback=self.parse)
  
      def parse(self, response):
          for line in response.css('div.b'):
              yield {
                  'right_column': line.css('div.m1').extract(),
                  'left_column': line.css('div.m2').extract(),
  }
  </code></pre>
  <p>And I run that with <code>scrapy crawl moulavi -o moulavi.json</code>.</p>
  <p>I knom my scrpit is not correct for now.
  I want to add the title of each page to the json file inside the <strong>&quot;def title&quot;</strong> and then call the <strong>&quot;def parse&quot;</strong> to add the other data to the json file. But as I'm not very familiar with callback or yield, so don't know what to do.</p>
  <p>As you can see in my code, I have commented the line which is the spot I want the title be added into the json file, but don't know how to do that.</p>
  <p>So what I want to do is to <strong>scrape</strong> the url, find the title of the page and then write it to the json file, and after that, start the for loop to find all div tags with class 'm1' and 'm2' and write them into the json file. And then start to scrape the next url.</p>
  <p>I want to have output like this:  (not suro if the syntax is correct)</p>
  <pre><code>{
  &quot;title&quot;:&quot;first page title&quot;,
  &quot;content&quot;:[
      {&quot;right_column&quot;: [&quot;&lt;div class=\&quot;m1\&quot;&gt;&lt;p&gt;من چگونه هوش دارم پیش و پس&lt;/p&gt;&lt;/div&gt;&quot;], &quot;left_column&quot;: [&quot;&lt;div class=\&quot;m2\&quot;&gt;&lt;p&gt;چون نباشد نور یارم پیش و پس&lt;/p&gt;&lt;/div&gt;&quot;]},
      {&quot;right_column&quot;: [&quot;&lt;div class=\&quot;m1\&quot;&gt;&lt;p&gt;عشق خواهد کین سخن بیرون بود&lt;/p&gt;&lt;/div&gt;&quot;], &quot;left_column&quot;: [&quot;&lt;div class=\&quot;m2\&quot;&gt;&lt;p&gt;آینه غماز نبود چون بود&lt;/p&gt;&lt;/div&gt;&quot;]},
      {&quot;right_column&quot;: [&quot;&lt;div class=\&quot;m1\&quot;&gt;&lt;p&gt;آینت دانی چرا غماز نیست&lt;/p&gt;&lt;/div&gt;&quot;], &quot;left_column&quot;: [&quot;&lt;div class=\&quot;m2\&quot;&gt;&lt;p&gt;زانک زنگار از رخش ممتاز نیست&lt;/p&gt;&lt;/div&gt;&quot;]}
  ]
  &quot;title&quot;:&quot;second page title&quot;,
  &quot;content&quot;:[
      {&quot;right_column&quot;: [&quot;&lt;div class=\&quot;m1\&quot;&gt;&lt;p&gt;بشنو این نی چون شکایت می‌کند&lt;/p&gt;&lt;/div&gt;&quot;], &quot;left_column&quot;: [&quot;&lt;div class=\&quot;m2\&quot;&gt;&lt;p&gt;از جداییها حکایت می‌کند&lt;/p&gt;&lt;/div&gt;&quot;]},
      {&quot;right_column&quot;: [&quot;&lt;div class=\&quot;m1\&quot;&gt;&lt;p&gt;کز نیستان تا مرا ببریده‌اند&lt;/p&gt;&lt;/div&gt;&quot;], &quot;left_column&quot;: [&quot;&lt;div class=\&quot;m2\&quot;&gt;&lt;p&gt;در نفیرم مرد و زن نالیده‌اند&lt;/p&gt;&lt;/div&gt;&quot;]},
  ]}
  </code></pre>
  <p>Thank you in advance :)</p>