title: TheGuardian API - Script crashes
body: <pre><code>import json
  import requests
  from os import makedirs
  from os.path import join, exists
  from datetime import date, timedelta
  
  ARTICLES_DIR = join('tempdata', 'articles')
  makedirs(ARTICLES_DIR, exist_ok=True)
  
  API_ENDPOINT = 'http://content.guardianapis.com/search'
  my_params = {
      'q': 'coronavirus,stock,covid',
      'sectionID': 'business',
      'from-date': &quot;2019-01-01&quot;,
      'to-date': &quot;2020-09-30&quot;,
      'order-by': &quot;newest&quot;,
      'show-fields': 'all',
      'page-size': 300,
      'api-key': '### my cryptic key ###'
  }
  
  
  # day iteration from here:
  # http://stackoverflow.com/questions/7274267/print-all-day-dates-between-two-dates
  start_date = date(2019, 1, 1)
  end_date = date(2020,9, 30)
  dayrange = range((end_date - start_date).days + 1)
  for daycount in dayrange:
      dt = start_date + timedelta(days=daycount)
      datestr = dt.strftime('%Y-%m-%d')
      fname = join(ARTICLES_DIR, datestr + '.json')
      if not exists(fname):
          # then let's download it
          print(&quot;Downloading&quot;, datestr)
          all_results = []
          my_params['from-date'] = datestr
          my_params['to-date'] = datestr
          current_page = 1
          total_pages = 1
          while current_page &lt;= total_pages:
              print(&quot;...page&quot;, current_page)
              my_params['page'] = current_page
              resp = requests.get(API_ENDPOINT, my_params)
              data = resp.json()
              all_results.extend(data['response']['results'])
              # if there is more than one page
              current_page += 1
              total_pages = data['response']['pages']
  
          with open(fname, 'w') as f:
              print(&quot;Writing to&quot;, fname)
  
              # re-serialize it for pretty indentation
              f.write(json.dumps(all_results, indent=2))
  
  ---------------------------------------------------------------------------
  KeyError                                  Traceback (most recent call last)
  &lt;ipython-input-18-f04b4f0fe9ed&gt; in &lt;module&gt;
       49             resp = requests.get(API_ENDPOINT, my_params)
       50             data = resp.json()
  ---&gt; 51             all_results.extend(data['response']['results'])
       52             # if there is more than one page
       53             current_page += 1
  
  KeyError: 'results'
  </code></pre>
  <blockquote>
  <p>Same error occurs for 'pages'</p>
  <p>At first there was no issues and was able to run it. Download crashed after 2020-03-24. Since then can't get the code running again.</p>
  </blockquote>
  <p>I'm referring to Line 51 and 54. At least at this point the codes crashes.
  Not sure how to get rid of the issue. Any ideas?</p>