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
29 1 4 12

How to clear special character in news extracted from eikon api

Hi team, I encountered a question regarding eikon api retrieving news. The news body contains too many special characters, hyper links as well delimiters. Is there any way to clean them up and only keep the raw text? I've attached my code below and the original news from workspace. Thanks for the help.

1700535282789.png

1700535364526.png

eikon-data-api#technology#productpython apinews
1700535282789.png (55.0 KiB)
1700535364526.png (70.2 KiB)
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.

1 Answer

· Write an Answer
Upvote
Accepted
79.2k 251 52 74

@Julian.Bai

Thank you for reaching out to us.

You can use the Refinitiv Data Library for Python instead to get news.

text = rd.news.get_story("urn:newsml:reuters.com:20231121:nHKS3l2gW4:1", format=rd.news.Format.TEXT)
print(text)

With the Refinitiv Data Library for Python, you can specify the news story's format (HTML or TEXT).

The sample code is available on GitHub.

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.

Hi Jira, thanks for the reply. The new command did help to cleaned up special characters, but it truncated quite a lot text.

text = rd.news.get_story("urn:newsml:reuters.com:20231113:nL4S3CE14O:1", format=rd.news.Format.TEXT)

print(text)

Original news:

1700563399600.png

News extracted:

1700563414385.png

Every line was truncated right in front of a hyper link or RIC. Is that some bugs or any other adjustments I need to do? Thank you.

1700563399600.png (66.0 KiB)
1700563414385.png (15.6 KiB)

@Julian.Bai

This is what I get from the API.

1700568715153.png


1700568715153.png (33.9 KiB)
Thanks Jira, I'll try again later on my side.

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.