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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
11 2 2 3

HTML to TEXT style (News story)

Hi

I would like to get news in text in Jupyter Notebook.

But I can get news only in HTML.

How can I get text style news story?

headlines = ek.get_news_headlines('IBM') for index, headline_row in headlines.iterrows(): story=ek.get_news_story(headline_row['storyId'])

print (story, content-Type: text/html)

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythonnewshtml
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.

Upvote
Accepted
38.1k 71 35 53

With Jupyter Notebook, you can use HTML() to display it as HTML.

from IPython.display import HTML
...

headlines = ek.get_news_headlines('IBM') 
for index, headline_row in headlines.iterrows(): story=ek.get_news_story(headline_row['storyId'])

HTML(story)


html.png (39.7 KiB)
text.png (42.6 KiB)
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.

Upvotes
4.3k 2 4 5

A Python library is available for this : https://pypi.python.org/pypi/html2text

There is more info here : https://github.com/Alir3z4/html2text/blob/master/docs/usage.md

Simple example with options:

import html2text
...
text_maker = html2text.HTML2Text()
text_maker.ignore_links = True
text_maker.bypass_tables = False
html_story = ek.get_news_story(headline_row['storyId'])
text_story = = text_maker.handle(html_story)
print(text_story)
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.

Upvotes
11 2 2 3

I could get text based news. Thank you guys for your support.

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