Hi,
I'm trying to iterate through several RICs and dates collecting news stories using this, and variations of this.
In the code below, x is a list of anywhere from 3 to 500 RICs.
for y in dates[1::60]: sdate = y edate = y edate += timedelta(days=60) str_sdate = sdate.strftime("%d-%b-%Y %H:%M:%S.%f") str_edate = edate.strftime("%d-%b-%Y %H:%M:%S.%f") q="R:" + x + ' Language:LEN AND NS:RTRS US AND -BRIEF -FACTBOX -IMBALANCE -AA -MOODY -MEDIA-' stories = ek.get_news_headlines(q, date_from = str_sdate, date_to = str_edate, count = 100)
When I run it, it works for anywhere between 1 minute and 20 minutes, giving me a few dozen or a few hundred results, but it always eventually fails with this error code:
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) <ipython-input-4-772ef7887bd0> in <module> 14 str_edate = edate.strftime("%d-%b-%Y %H:%M:%S.%f") 15 q="R:" + x + ' Language:LEN AND NS:RTRS US AND -BRIEF -FACTBOX -IMBALANCE -AA -MOODY -MEDIA-' ---> 16 stories = ek.get_news_headlines(q, date_from = str_sdate, date_to = str_edate, count = 100) 17 storycount = stories['versionCreated'].count() 18 ~\Anaconda3\lib\site-packages\eikon\news_request.py in get_news_headlines(query, count, date_from, date_to, raw_output, debug) 124 return result 125 else: --> 126 return get_data_frame(result) 127 128 ~\Anaconda3\lib\site-packages\eikon\news_request.py in get_data_frame(json_data) 133 'sourceName', 'versionCreated'] 134 --> 135 json_headlines_array = json_data['headlines'] 136 first_created = [tz_replacer(headline['firstCreated']) for headline in json_headlines_array] 137 headlines = [[headline[field] for field in Headline_Selected_Fields] KeyError: 'headlines'
I have tried shortening my query to make it simpler, taking out everything but language, RIC and news source. I have tried inserting a 3 second delay between each iteration in case there is some limit on how often I can make a request, but no matter what I change, I always eventually get the "KeyError: 'headlines'" error.
I see other questions have been asked about "KeyError: Header" but I can't see anything related to "KeyError: Headline".
Thank you