M
M
marataziat2017-06-14 15:05:44
YouTube
marataziat, 2017-06-14 15:05:44

Why does an error appear, are supernatural forces involved in this?

import requests, json
key = ""
req = json.loads(requests.get("https://www.googleapis.com/youtube/v3/search?key=%sU&channelId=UCgxTPTFbIbCWfTR9I2-5SeQ&part=snippet,id&order=date&maxResults=50" % key).text)
for i in req['items']:
   print "videoId: ", i['id']['videoId']

Why am I getting an error :(?:
Traceback (most recent call last):
  File "/Users/seal/PycharmProjects/Randomtube/app.py", line 5, in <module>
videoId:  3D6m4WFBt5A
    print "videoId: ", i['id']['videoId']
videoId:  yO1A6Y5acpY
KeyError: 'videoId'
videoId:  v3nvOKDwgvg
videoId:  YKTBY35152w
videoId:  Hf7IqZ_KF7w
videoId:  e1Rf2zobcaw
videoId:  OyV9W_IXatE
videoId:  Yasjlu1iTT0
videoId:  xyYZlR_Ibmc
videoId:  jI8_ddgB_aQ
videoId:  52SW1YfqWio
videoId:  lN_zQRh4WZ4
videoId:  kAMB14V7iT8
videoId:  w-ZF78sczFg
videoId:  ISmCwHXfqFs
videoId:  fWlbTggRKqU
videoId:  jBYFIQ1rx-M
videoId:  lgW5yc9NxQA
videoId:  eYRsmBJJhis
videoId:  dhIfakVqX9A
videoId:  rnl5O2BLilc
videoId:  FsbMDpTQupE
videoId: 

Process finished with exit code 1

Shit like this pops up randomly!
Traceback (most recent call last):
  File "/Users/seal/PycharmProjects/Randomtube/app.py", line 5, in <module>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
longclaps, 2017-06-14
@marataziat

In such cases it is difficult to say something meaningful.
Well, it's written in red and white: It's obvious that there is no 'videoId' in this element. Check for availability.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question