Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
3 1 2 3

EIKON API: News headline and story

Currently, I'm using the coding to retrieve the story below. I'd like to add the headline of the news. How can I do it?

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

articledata=""


headlines = ek.get_news_headlines(query='JPXエネルギー',count=1)

story = headlines.iat[0,2]

data_all=ek.get_news_story(story)


maru_count_list = []

for m in re.finditer('。', data_all):

maru_count_list.append(m.end())


html_story = data_all[0:maru_count_list[1]]


soup = BeautifulSoup(html_story, 'html.parser')

articledata = [i.get_text() for i in soup.select('p')]

print(headlines)

print(articledata)

# type(articledata)


articledata

eikoneikon-data-apirefinitiv-dataplatform-eikonworkspaceworkspace-data-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

@tnksnsk314

Hi,

Thank you for your participation in the forum.

Is the reply below satisfactory in answering your question?

If yes please click the 'Accept' text next to the reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,

AHS

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,


AHS

1 Answer

· Write an Answer
Upvotes
Accepted
18.2k 21 13 21
headlines = ek.get_news_headlines(query='JPXエネルギー',count=1)
headlineText = headlines.iat[0,1]
print(headlineText)

storyID = headlines.iat[0,2]
print(storyID)

storyText = ek.get_news_story(storyID)
print(storyText)


import csv
output_file = open('output_file.csv', mode='w',encoding="utf-8")
output_writer = csv.writer(output_file)

output_writer.writerow(['StoryID','HeadlineText','StoryText'])
output_writer.writerow([storyID, headlineText, storyText])

output_file.close()


You can use the code to get story, story id and headline.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.