title: Scrapy: how to create a dict output with XPATH iterate in a table <tr><td>
body: <p>I have this html structure:</p>
  <pre><code>&lt;table&gt;
    &lt;tbody&gt;
      &lt;tr&gt;....&lt;/tr&gt;
      &lt;tr&gt;....&lt;/tr&gt;
      &lt;tr&gt;....&lt;/tr&gt;
        &lt;td align= &quot;right&quot; bgcolor=&quot;#ffffff&quot;&gt;...&lt;/td&gt;
        &lt;td bgcolor=&quot;efefef&quot;&gt;...&lt;/td&gt;
        &lt;td align= &quot;right&quot; bgcolor=&quot;#ffffff&quot;&gt;...&lt;/td&gt;
        &lt;td bgcolor=&quot;efefef&quot;&gt;...&lt;/td&gt;
      &lt;tr&gt;....&lt;/tr&gt;
  </code></pre>
  <p>In the table, each tr has 4 td's , i need to create an output dict that the text in the first td is a key, the second a value for that key , the third a new key , and the fourth a value for that key. And do this for every tr in the table.</p>
  <p>I tried this in my spider:</p>
  <p>this is the XPATH to the table: /html/body/table[3]/tbody/tr/td[1]/table/tbody/tr</p>
  <pre><code>def parse(self, response):
          
          for row in response.xpath('/html/body/table[3]/tbody/tr/td[1]/table/tbody/tr'):
  
             key1 = row.xpath(&quot;/td[0][@align='right']/font[@size='2']/text()&quot;).extract()
             value1 = row.xpath(&quot;/td[1]/[@bgcolor='#efefef']/descendant::text()&quot;).extract()
             key2 = row.xpath(&quot;/td[2][@align='right']/font[@size='2']/text()&quot;).extract()
             value2 = row.xpath(&quot;/td[3]/[@bgcolor='#efefef']/descendant::text()&quot;).extract()
  
              yield{
                  key1 : value1,
                  key2 : value2
              }
  </code></pre>
  <p>Tried this but not working. I'm new to XPATH and scrapy, I don't know how to do this kind of thing. I extracted the keys and values ​​in separate arrays, but this way does not solve my problem, I need to extract them with their respective key-value pair.</p>