In Eikon, news code [HNXB] contains headlines with links to download the file. Is there a way for us to download the data frame directly via Codebook? I'm only able to get the headlines but couldn't find a code that would extract the data directly.
ek.get_news_headlines(query = 'HNXB', count=10)
@chrisma.salut So im thinking that you are looking to retrieve the news stories - so get_news headlines returns a dataframe of max 100 items per API call corresponding to a query you give it - in your case 'HNXB'.
df = ek.get_news_headlines(query = 'HNXB', count=10) df
So this returns a dataframe of 10 headline items and you need to pass the storyId to a second API called get_news_story - which will return you the html formatted story text. The folllowing routine stores the formatted html news story in a new column called storytext.
df['storytext'] = '' for i, uri in enumerate(df['storyId']): df['storytext'][i] = ek.get_news_story(uri) df
You can display the story using:
from IPython.display import HTML HTML(df['storytext'])
I have noticed in your query the news story text is actually a download link - if you changed the query to say VOD.L and repeated the exercise - it would display a news item. It is working correctly. I hope this can help.
Hi all, I dont verified your answers because it doenst match the requirement : downloading the file not the news. I found out my own way without applying any side to side api :
###1. get the table news
###2. get the story id
###2. get the file (downloaded in download folder)
link1 = re.search('href="(.*)" data-type', df1_url)