title: Scraping web data from JSON with python
body: <p>I would like to scrape timetable data from <a href="https://booking.snav.it/api/v1/rates/1040/2019-02-25/1042/2019-02-25?lang=1" rel="nofollow noreferrer">this API</a>. The data returned is in JSON format. I'm using python.</p>
  
  <p>I've tried the following code:</p>
  
  <pre><code>snav_timetable_url = "https://booking.snav.it/api/v1/rates/1040/2019-02-25/1042/2019-02-25?lang=1"
  fh = urllib.request.urlopen(snav_timetable_url)
  snav_timetable = fh.read().decode('utf-8')
  fh.close()
  snav_timetable_data = json.loads(snav_timetable[len(snav_timetable)-2])
  snav_timetable_data_cleaned = []
  for departure in snav_timetable_data ['data']['ratesOutward']:
      snav_timetable_data_cleaned.append({
         'COMPANY': 'Snav',
         'CODICE CORSA': departure['coditinera'],
         'DEPARTURE DATE TIME': departure['strDatapart'],
         'ARRIVAL DATE TIME': departure['strDatarri']
      })
  </code></pre>
  
  <p>but get error</p>
  
  <pre><code>    raise JSONDecodeError("Expecting value", s, err.value) from None
  json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
  </code></pre>
  
  <p>What am I doing wrong?</p>