title: How to access nested keys and their values to modify or delete all at once?
body: <p>Learning python and stuff due to my need of collecting bunch of data for my project and I am stuck here. I am using scrapy to scrape a json response from an API which looks like this;</p>
  <pre><code>  &quot;status&quot;: &quot;ok&quot;,
    &quot;status_message&quot;: &quot;Query was successful&quot;,
    &quot;data&quot;: {
      &quot;product_count&quot;: 40993,
      &quot;limit&quot;: 20,
      &quot;page_number&quot;: 1,
      &quot;products&quot;: [
        {
          &quot;id&quot;: 41789,
          &quot;url&quot;: &quot;https://anything1.com&quot;,
          &quot;product_name&quot;: &quot;product1&quot;,
          &quot;manufacturing_date&quot;: &quot;19.12.2014&quot;,
          &quot;rating&quot;: 5.3,
          &quot;material&quot;: &quot;something&quot;,
          &quot;description&quot;: &quot;&quot;,
          &quot;cover_image&quot;: &quot;anycover1.com&quot;,
          &quot;state&quot;: &quot;ok&quot;,
          &quot;variants&quot;: [
            {
              &quot;url&quot;: &quot;https://anyvariant1.com&quot;,
              &quot;product_code&quot;: &quot;55BEF7&quot;,
              &quot;material&quot;: &quot;something&quot;,
              &quot;size&quot;: &quot;small&quot;,
              &quot;dimensions&quot;: &quot;&quot;          },
            {
              &quot;url&quot;: &quot;https://anyvariant2.com&quot;,
              &quot;product_code&quot;: &quot;55BEF8&quot;,
              &quot;material&quot;: &quot;something&quot;,
              &quot;size&quot;: &quot;medium&quot;,
              &quot;dimensions&quot;: &quot;&quot;          },
            {
              &quot;url&quot;: &quot;https://anyvariant3.com&quot;,
              &quot;product_code&quot;: &quot;55BEF9&quot;,
              &quot;material&quot;: &quot;something&quot;,
              &quot;size&quot;: &quot;large&quot;,
              &quot;dimensions&quot;: &quot;&quot;          }          
          ]
        },
        {
          &quot;id&quot;: 41790,
          &quot;url&quot;: &quot;https://anything2.com&quot;,
          &quot;product_name&quot;: &quot;product2&quot;,
          &quot;manufacturing_date&quot;: &quot;02.10.2014&quot;,
          &quot;rating&quot;: 7.2,
          &quot;material&quot;: &quot;something&quot;,
          &quot;description&quot;: &quot;&quot;,
          &quot;cover_image&quot;: &quot;anycover2.com&quot;,
          &quot;state&quot;: &quot;ok&quot;,
          &quot;variants&quot;: [
            {
              &quot;url&quot;: &quot;https://anyvariant4.com&quot;,
              &quot;product_code&quot;: &quot;55BEG7&quot;,
              &quot;material&quot;: &quot;something&quot;,
              &quot;size&quot;: &quot;small&quot;,
              &quot;dimensions&quot;: &quot;&quot;          },
            {
              &quot;url&quot;: &quot;https://anyvariant5.com&quot;,
              &quot;product_code&quot;: &quot;55BEG8&quot;,
              &quot;material&quot;: &quot;something&quot;,
              &quot;size&quot;: &quot;medium&quot;,
              &quot;dimensions&quot;: &quot;&quot;          },
            {
              &quot;url&quot;: &quot;https://anyvariant6.com&quot;,
              &quot;product_code&quot;: &quot;55BEG9&quot;,
              &quot;material&quot;: &quot;something&quot;,
              &quot;size&quot;: &quot;large&quot;,
              &quot;dimensions&quot;: &quot;&quot;          }          
          ]
        },
        {
          _______
        },
        {
          _______
        }      
      ]
    },
    &quot;@meta&quot;: {
      &quot;server_time&quot;: 1651288705,
      &quot;execution_time&quot;: &quot;0.01 ms&quot;
    }
  }
  </code></pre>
  <p>And this is how my scraper code looks like;</p>
  <pre><code>    data = json.loads(response.body)
      data_main = data['data']['products']
      product_list = []
      for item in data_main:
          id = item['id']
          url = item['url']
          product_name = item['product_name']
          rating = item['rating']
          cover_image = item['cover_image']
          description = item['description']
          product = {
              'id': id,
              'url': url,
              'name': product_name,
              'image': cover_image,
              'rating': rating,
              'description': description
          }
          product_list.append(product)
      return product_list
  </code></pre>
  <p>With this keys and values of id, url, name, image, rating, description are accessible. But unable to access and modify the nested keys and their values all at once (and ignore some keys and values). So how can I do that? And if there is any other better code to achieve what I need then please suggest.
  Thanks a lot.</p>