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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
3 0 1 1

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-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikon
icon clock
10 |1500

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

1 Answer

Upvotes
Accepted
18k 21 12 20
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 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea